题目内容

Assume int[] scores = {1, 20, 30, 40, 50}, what value does java.util.Arrays.binarySearch(scores, 30) return?

A. 1
B. -2
C. 0
D. 2

查看答案
更多问题

Analyze the following code: public class Test { public static void main(String[] args) { int[] x = new int[5]; int i;for (i = 0; i < x.length; i++)x[i] = i;System.out.println(x[i]);} }

A. The program displays 4.
B. The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException.
C. The program displays 0 1 2 3 4.
D. The program has a compile error because i is not defined in the last statement in the main methoD.

Analyze the following code: public class Test { public static void main(String[] args) { final int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for (int i = 0; i < y.length; i++)System.out.print(y[i] + " ");} }

A. The program displays 0 0
B. The elements in the array x cannot be changed, because x is final.
C. The program has a compile error on the statement x = new int[2], because x is final and cannot be changeD.
D. The program displays 1 2 3 4

The element in the array must be of a primitive data type.

A. false
B. true

Analyze the following code: public class Test { public static void main(String[] args) { int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for (int i = 0; i < y.length; i++)System.out.print(y[i] + " ");} }

A. The program displays 0 0
B. The program displays 0 0 3 4
C. The program displays 1 2 3 4
D. The program displays 0 0 0 0

答案查题题库