Java OCA OCP Practice Question 875

Question

Which of these four array references can point to an array that is different from the others?

  • A. int[][][][] arr1a, arr1b;
  • B. int[][][] arr2a[], arr2b;
  • C. int[][] arr3a[][], arr3b[][];
  • D. int[] arr4a[][][], arr4b[][][];


B.

Note

All of the variables except arr2b point to a 4D array.

Don't create a 4D array; it's confusing.

The options show the braces can be before or after the variable in any combination.

Option B is the answer because arr2b points to a 3D array.

It only has three pairs of braces before the variable and none after.

By comparison, arr2a has three pairs of braces before the variable and the fourth pair of braces after.




PreviousNext

Related