Looking for 367.044, VL Vertiefung Softwareentwicklung, Karin Anna Hummel, 2025S test answers and solutions? Browse our comprehensive collection of verified answers for 367.044, VL Vertiefung Softwareentwicklung, Karin Anna Hummel, 2025S at moodle.jku.at.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
// Person.javapackage unit01.quiz;public abstract class Person{ public abstract String talk();} // Student.java package unit01.quiz;public class Student extends Person{ private final String name; private final double gpa; // grade point average, higher is better private final String subject; // study subject public Student(String name, double gpa, String subject){ this.name = name; this.gpa = gpa; this.subject = subject; } public String talk(){ return name; } public String talk(String subject){ return (name+" is studying "+subject); } public String learn(){ return (name+" is studying "+subject); } public boolean evaluate(double gpaTest){ if (this.gpa < gpaTest) return false; else return true; } public String getSubject(){ return subject; } public double getGPA() { return gpa; }}// Main.java package unit01.quiz;public class Main { public static void main(String[] args) { Student student = new Student("Paul",3.2, "WINF"); }} Which code lines do NOT WORK OR DO NOT MAKE SENSE in main() (syntactically wrong or sentence makes not sense))?1) System.out.println("Student " + student.talk() + " is studying.");2) System.out.println("Student " + student.talk() + " is studying " + student.getSubject() + ".");3) System.out.println("Student " + student.talk() + " is studying " + student.getSubject(student.talk()) + ".");4) System.out.println("Student " + student.learn() + " is studying " + student.getSubject() + ".");5) System.out.println("Student " + student.talk() + " is studying " + student.getGPA() + ".");6) if (student.evaluate(2.0)) System.out.println(student.talk() + " has a better GPA than 2.0.");7) if (student.evaluate(2.0)) System.out.println(student.talk() + " has a worse GPA than 2.0.");8) System.out.println("Student " + student.talk(student.getSubject())+".");
// Course.javapackage unit01.quiz;public enum Course { ARTIFICIAL_INTELLIGENCE(536), COMPUTER_SCIENCE(521), BUSINESS_INFORMATICS(526); private int id; private Course(int id) { this.id = id; }}// Main.javapackage unit01.quiz;public class Main { public static void main(String[] args) { Course course = Course.BUSINESS_INFORMATICS; }} Which statements (in main()) will print "BUSINESS_INFORMATICS" to the terminal?1) System.out.println(BUSINESS_INFORMATICS);2) System.out.println(course);3) System.out.println(Course.BUSINESS_INFORMATICS);4) System.out.println(course.toString());5) System.out.println(course.name());6) System.out.println(course());7) System.out.println(Course(3));8) System.out.println(Course.values()[course.ordinal()]);
// Person.javapackage unit01.quiz;public abstract class Person { public abstract String talk();}// Student.javapackage unit01.quiz;public class Student extends Person{ private final String name; public Student(String name){ this.name = name; } // Student tells own name public String talk(){ return name; }} // Teacher.javapackage unit01.quiz;public class Teacher extends Person{ private final String subject; public Teacher(String subject){ this.subject = subject; } // Teacher tells about subject public String talk(){ return subject; }}// Main.javapackage unit01.quiz;public class Main { public static void main(String[] args) { Student student = new Student("Paul"); Teacher teacher = new Teacher("Maths"); }} Which of the following statements in main() are correct (Syntax correct)?1) System.out.println("Student " + student.name + " is being taught " + teacher.subject);2) System.out.println("Student " + Student.name + " is being taught " + Teacher.subject);3) System.out.println("Student " + Student.talk() + " is being taught " + Teacher.talk());4) System.out.println("Student " + student.talk() + " is being taught " + teacher.talk());
// Student.javapackage unit01.quiz;public class Student{ public static String university; private final String name; private double gpa; // grade point average public Student(String name, double gpa){ this.name = name; this.gpa = gpa; } public String getName(){ return name; } public void setGPA(double gpa){ if (gpa < 0 || gpa > 4.0) { System.out.println("Wrong argument value!"); } else { this.gpa = gpa; } }}// Main.javapackage unit01.quiz;public class Main { public static void main(String[] args) { Student student = new Student("Paul",3.2); }} Which statements do NOT WORK in main() (syntax errors or syntax warnings; note that the object student is already created in main())?1) Student.university = "JKU";2) student.name = "Walter";3) System.out.print(student.getName()+"'s University: " + Student.university); 4) student.setGPA(4.0); System.out.print(student.getName()+"'s GPA: " + student.gpa);
A simple, text-based MVC pattern should be implemented, which increments a counter upon user input (via the terminal). A counter is incremented whenever a user presses "return". The value that is displayed is the counter multiplied by a factor (value = counter * factor). Multiple views should be supported. The code - except the code for the model - is given as follows:
public class Quiz4 { static interface ModelListener { public void action(ModelEvent e); } static class ModelEvent { private final int counter; ModelEvent(int counter){ this.counter = counter; } public int getCounter() { return counter; } } static class View { View(Model model,int factor) { ModelListener l = e -> System.out.println("Counter x factor: " + e.getCounter()*factor); model.addListener(l); } } static class Control { public void requestInput(Model model) { while (true) { System.out.print("Press return: "); try { // read until newline/return is pressed while (System.in.read()!='\n'); } catch (IOException e) { e.printStackTrace(); } model.setCounter(model.getCounter()+1); } } } public static void main(String[] args) { // One model, one controller, two views Model model = new Model(); View view = new View(model,1); View view1 = new View(model,2); Control control = new Control(); control.requestInput(model); }}
Which of the following implementations of the model are correct (i.e., bug-free and supporting the required behavior)?
a) class Model { int counter = 0; List<ModelListener> ml = new ArrayList<>(); public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; for (ModelListener l : ml) { l.action(new ModelEvent(this.counter)); } } public void addListener(ModelListener l) { ml.add(l); } } b) class Model { int counter = 0; List<ModelListener> ml = new ArrayList<>(); public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; } public void addListener(ModelListener l) { ml.add(l); } }c) class Model { int counter = 0; ModelListener l = null; public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; if (l != null) { l.action(new ModelEvent(this.counter)); } } public void addListener(ModelListener l) { this.l = l; } }d) class Model { int counter = 0; List<ModelListener> ml = new ArrayList<>(); public int getCounter() { return counter; } public void setCounter(int counter) { this.counter = counter; for (ModelListener l : ml) { l.action(new ModelEvent(this.counter)); } } public void addListener(ModelListener l) { ml = null; } }
Which of the following statements about Java Swing are true?
a) User interfaces are compositions of JComponents.
b) Java AWT provides basic classes that may be used by Swing components.
c) Layout managers provide re-/painting methods of an area.
d) When designing a chess game, a GridLayout is a good choice for the game field.
Which of the following statements about MVC (model-view-controller) are true?
a) MVC is an architectural pattern and uses the software design pattern observer.
b) MVC allows to have multiple views operating with the same model.
c) The listeners of mouse events or button clicks are implemented in the model.
d) The model listeners are implemented in the model.
The following code is intended to show quotes; it provides a window, a button, a text (JLabel), and another button:
JFrame frame = new JFrame("Quote"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(400, 300); frame.setLayout(new BorderLayout()); JButton quoteButton = new JButton("Show Quote"); frame.add(quoteButton,BorderLayout.NORTH); JLabel quoteText = new JLabel("Quote coming soon ..."); quoteText.setHorizontalAlignment(SwingConstants.CENTER); frame.add(quoteText,BorderLayout.CENTER); JButton anotherQuoteButton = new JButton("Show Quote");
frame.setVisible(true);
Assume you want to show a quote in quoteText (a text in HTML format, <br> is the tag for line break) when pressing quoteButton or anotherQuoteButton. Which of the following statements enable this behavior for at least one of the buttons?
a)
quoteText.addActionListener(e -> { quoteText.setText("<html> There are 10 kind of people,<br> those who understand binary, <br> and those who don’t.</html>"); frame.repaint(); });
b)
quoteButton.addActionListener(e-> { quoteButton.setText("<html> There are 10 kind of people,<br> those who understand binary, <br> and those who don’t.</html>"); frame.repaint(); });
c)
quoteButton.addActionListener(e-> { quoteText.setText("<html> There are 10 kind of people,<br> those who understand binary, <br> and those who don’t.</html>"); frame.repaint(); });
d)
anotherQuoteButton.addActionListener(e-> { quoteText.setText("<html> There are 10 kind of people,<br> those who understand binary, <br> and those who don’t.</html>"); frame.repaint(); });
Which of the following statements are true about JUnit5 tests?
a) Before executing a test, you should be sure about the context (values and conditions) of the objects used in this test.
b) In a JUnit test method, an exception thrown by the code under test always leads to an error.
c) A JUnit test case can proof that the code under test has no errors.
d) Several JUnit test class files may be created using/testing the same class under test.
Which of the following are bad design choices?
a) Design multiple functions that realize similar functionality.
b) Avoid coupling within classes.
c) Do not pack several elementary functionalities together in one method.
d) Avoid extensive coupling between classes.