- •Import java.Util.*;
- •II and III only
- •I and II only
- •24) Consider the following uml class diagram.
- •25) Consider the following uml class diagram.
- •II only
- •30) Consider the following class definitions.
- •III only
- •I and II only
- •II only
- •I and III only
- •II and III only
- •I and II only
- •I and III only
- •II only
- •I and III only
I and II only
60) Consider the following Java program segment.
class Aircraft { void takeOff() {...} } class Helicopter extends Aircraft { void takeOff() {...} } ... Helicopter h = new Helicopter(); Aircraft a = new Aircraft(); Aircraft ah = new Helicopter();
Execution of which of the following lines would cause the method takeoff of the class Helicopter to be executed?
h.takeOff();
a.takeOff();
ah.takeoff();
I and III only
61) In Java, which of the following can appear in abstract classes but not in interfaces?
Definitions of instance variables
Implementation of methods
Implementation of constructors
I, II, and III
62) In Java, which of the following is (are) true regarding interfaces?
An interface can extend a class.
An interface can extend multiple interfaces.
II only
63) A singleton class typically refers to its instance via a _____ variable.
private static
64) In singleton classes, the constructor is _____ to ensure that instantiation is controlled through a(n) _____ method.
private, static
65) Which of the following is (are) true regarding the strategy design pattern?
A family of algorithms are combined into a large single method.
Polymorphism is used.
II only
66) In a strategy design pattern, the desired algorithm is specified and invoked via a(n)
context class
67) What kinds of abstract classes, if any, can be instantiated?
None
68) In Java, for a subclass of an abstract class not to be abstract, the subclass must override which of the following?
All inherited abstract methods
All inherited methods that are not abstract
I only
69) Consider the following line of Java code.
PrintWriter fileOut = new PrintWriter(new FileWriter("out.txt", true));
Which of the following is (are) true about the result of executing the line of code?
If the file out.txt exists, its contents will be erased.
If the file out.txt does not exist, it will be created.
II only
70) Which of the following is (are) true regarding file input in Java?
FileReader and BufferedReader are defined in the package java.lang.
A BufferedReader object can receive data from a FileReader object.
A BufferedReader object can read entire lines of data.
II and III only
71) In Java, which of the following registers a listener for a radio button click event?
addActionListener
72) Which of the following is a line of code that registers a named inner class as an event listener for a JList object in Java?
addListSelectionListener(new ListListener());
73) In Java, which of the following is (are) true regarding JTextArea objects?
They support background and foreground colors.
They have built-in scrollbar capability.
They can be read-only.
I and III only
74) Which of the following is (are) true regarding event handling in Java?
A single listener object can be registered to handle all button presses in an application.
A different listener object can be registered with each button in an application.
I and II
75) In Java, which of the following terminates a program?
System.exit(0)
76) A user clicking a JButton component in Java generates which of the following events?
Action
Mouse pressed
Mouse clicked
I, II, and III
77) Which of the following is a Java layout manager that automatically wraps components to the next available row if they cannot fit on the current row?
FlowLayout
