题目内容

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

Analyze the following code.int[] list = new int[5];list = new int[6];

A. The code has compile errors because you cannot assign a different size array to list.
B. The code can compile and run fine. The second line assigns a new array to list.
C. The code has runtime errors because the variable list cannot be changed once it is assigneD.
D. The code has compile errors because the variable list cannot be changed once it is assigneD.

Analyze the following code: public class Test {public static void main(String[] args) {int[] a = new int[4];a[1] = 1;a = new int[2];System.out.println("a[1] is " + a[1]);} }

A. The program has a compile error because new int[2] is assigned to A.
B. The program displays a[1] is 1.
C. The program has a runtime error because a[1] is not initializeD.
D. The program displays a[1] is 0.

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

A. The program displays 0 1 2 3 4.
B. The program displays 0 1 2 3 4 5.
C. The program displays 0 1 2 3 4 and then raises a runtime exception.
D. The program displays 0 1 2 3 4 5 and then raises a runtime exception.

答案查题题库