
- •11. Which of the following statements imports the entire package java.Util into a Java program? (a) import util; (b) import util.*; (c) import java.Util.*; (d) import java.Util;
- •13. After a breakpoint is hit, a debugger is typically used for which of the following tasks?
- •I. Stepping through method calls, line by line II. Examining a stack trace
- •III. Examining values of variables in the current method
- •36. Consider the following Java program segment.
- •37. If a class contains a constructor, that constructor will be invoked
- •39. Consider the following uml class diagram.
- •Which of the following kinds of associations is not indicated by the class diagram?
- •47. Consider the following uml class diagram.
- •Which of the following may be substituted for X in the above diagram to represent a multiplicity between a and b?
- •61. Consider the following Java program segment.
- •83. In object-oriented design, types of multiplicity for associations among classes include which of the following?
- •(A) I and II only (b) I, II, and III (c) I and III only (d) II and III only
- •96. In Java, which of the following is (are) true regarding interfaces?
- •I. An interface can extend a class. II. An interface can extend multiple interfaces. (a) I only (b) None (c) I and II (d) II only
- •99. Which of the following is (are) true regarding the strategy design pattern?
- •I. A family of algorithms are combined into a large single method. II. Polymorphism is used.
- •106. Which of the following Java program segments will compile and execute without error?
- •System.Out.Println(numbers[I]);
- •System.Out.Println(numbers[I]);
- •107. Consider the following uml class diagram.
- •109. Consider the following uml class diagram.
- •111. Consider the following uml class diagram.
- •115. Which of the following Java method declarations does not require that the method return a value? (a) private int myMethod(); (b) private static int myMethod();
61. Consider the following Java program segment.
String[] str = {"Three","Two","One"};
for (int i = 0; i < str.length; ++i) {
System.out.println(str[i]+"/");
}
What will be output upon execution of the program segment?
(a) Three/Two/One/ (b) Three,Two,One (c) One,Two,Three (d) One/Two/Three/
62. Regarding the following declaration, what is the index of the element containing 45?
int[] numbers = {-1, 45, 6, 132};
(a) 2 (b) 0 (c) 45 (d) 1
63. In Java, which of the following can appear in abstract classes but not in interfaces?
I. Definitions of instance variables
II. Implementation of methods
III. Implementation of constructors
(a) II and III only (b) I and II only (c) I, II, and III (d) I only
64. If a file opened for reading does not exist, which of the following events will occur in Java?
(a) A NullPointerException will be raised.
(b) A run-time error will occur.
(c) A FileNotFoundException will be raised.
(d) A new file will be created.
65. In Java, the default layout manager for a JFrame component is
(a) GridLayout (b) FlowLayout (c) GridBagLayout (d) BorderLayout
66. In singleton classes, the constructor is _____ to ensure that instantiation is controlled through a(n) _____ method.
(a) omitted, static (b) private, instance (c) private, static (d) omitted, instance
67. The model part of the Model-View-Controller (MVC) paradigm embodies the
(a) abstract domain knowledge of an application
(b) way in which the abstract domain knowledge of an application is presented to the user
(c) automatic mechanism by which the user interface is displayed and by which events are communicated between the view and the controller
(d) list of abstract classes in an application
68. A reference variable r in Java can hold a reference to which of the following?
I. An object having the same declared type as r
II. An object of any subclass of the declared type of r
III. An object of any superclass of the declared type of r
(a) I, II, and III only (b) I and III only (c) I only (d) I and II only
69. Consider the Java program below.
public class Arr{
public static void main(String[] args) {
int[] a = {1, 2, 3};
System.out.println(a[1]);
System.out.println(a[3]);
}
}
Which of the following is true about the result of executing the program?
(a) The number 2 is printed and a run-time exception terminates execution.
(b) The number 2 is printed and there is no abnormal termination.
(c) The number 1 is printed and there is no abnormal termination.
(d) The number 3 is printed and a run-time exception terminates execution.
70. Which of the following is (are) true regarding file input in Java?
I. FileReader and BufferedReader are defined in the package java.lang.
II. A BufferedReader object can receive data from a FileReader object.
III. A BufferedReader object can read entire lines of data.
(a) I and II only (b) II and III only (c) I and III only (d) I, II, and III
71. Legal Java statements to initialize an array reference include which of the following?
I .int[] aobj = {0, 1, 2}; II .int[4] aobj = {0, 1, 2}; III .int[] aobj = new int[3];
(a) III only (b) I and II only (c) I and III only (d) I only
72. A Java array that contains n components will be indexed from _____ through _____.
(a) 0, n-1 (b) 0, n (c) 1, n (d) 1, n-1
73. Which of the following methods is (are) provided by java.util.Iterator?
I .next, which causes an iterator to return the next item in its iteration
II .remove, which can remove an item from a collection associated with an iterator
(a) I only (b) II only (c) I and II (d) None
74. Which of the following statements is not true of the class java.util.Vector?
(a) Once an object is inserted into an instance of Vector, it can never be removed.
(b) Items stored by an instance of Vector can be accessed using integer indexes.
(c) The constructor of the Vector class, when called with no arguments, causes an empty vector to be constructed.
(d) An instance of Vector can store any object whose class descends from java.lang.Object.
75. 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?
(a) addActionListener(this); (b) addListSelectionListener(this);
(c) addListSelectionListener(new ListListener()); (d) addActionListener(new ListListener());
76. An object that contains methods that traverse a vector linearly from start to finish is known as a(n)
(a) iterator (b) Exception (c) int (d) loop
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?
(a) GridLayout (b) FlowLayout (c) GridBagLayout (d) BorderLayout
78. In which of the following ways can items be added to a collection implemented by java.util.Vector?
I .Items can be inserted at the beginning of the collection.
II .Items can be inserted between two existing items in the collection.
III .Items can be appended to the end of the collection.
(a) I, II, and III (b) III only (c) I and III only (d) I only
79. In Java, which of the following terminates a program?
(a) dispose() (b) System.exit(0) (c) actionPerformed() (d) windowClosing()
80. Consider the following line of code, where v is an instance of java.util.Vector.
Integer i = v.get(0);
For which of the following reasons will this line of code fail to compile?
(a) The line does not cast the object returned by v.get to an Integer.
(b) The method get is not defined in java.util.Vector.
(c) The line attempts to retrieve an instance of Integer from a vector.
(d) The value 0 is not a valid index for a vector.
81. Which of the following statements is (are) true in Java?
I .Classes that contain abstract methods must be declared abstract.
II .Classes that contain protected methods must be declared abstract.
(a) I and II (b) None (c) I only (d) II only
82. Which of the following statements is (are) true about any abstract method in Java?
I .It contains no definition.
II .It cannot be declared public.
(a) None (b) I only (c) II only (d) I and II