Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
javaСЎФсМв_115.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
101.38 Кб
Скачать

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

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]