题目内容

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 < x.length; i++)System.out.print(x[i] + " ");} }

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

查看答案
更多问题

Analyze the following code: public class Test {public static void main(String[] args) {double[] x = {2.5, 3, 4};for (double value: x)System.out.print(value + " ");} }

A. The program has a syntax error because value is undefineD.
B. The program displays 2.5 3.0 4.0
C. The program displays 2.5, 3, 4
D. The program displays 2.5, 3.0 4.0

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

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

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

A. The program displays 1 2 3 4 5 and then raises an ArrayIndexOutOfBoundsException.
B. The program displays 1 2 3 4 5.
C. The program displays 5 4 3 2 1.
D. The program displays 5 4 3 2 1 and then raises an ArrayIndexOutOfBoundsException.

If a key is not in the list, the binarySearch method returns _________.

A. insertion point
B. insertion point - 1
C. -(insertion point + 1)
D. -insertion point

答案查题题库