Which two are valid instantiations and initializations of a multi dimensional array?
A.
int [] [] array 2D = { { 0, 1, 2, 4} {5, 6}};
B.
int [] [] array2D = new int [2] [2];
array2D[0] [0] = 1;
array2D[0] [1] = 2;
array2D[1] [0] = 3;
array2D[1] [1] = 4;
C.
int [] [] [] array3D = {{0, 1}, {2, 3}, {4, 5}};
D.
int [] [] [] array3D = new int [2] [2] [2];
array3D [0] [0] = array;
array3D [0] [1] = array;
array3D [1] [0] = array;
array3D [0] [1] = array;
E.
int [] [] array2D = {0, 1};
Explanation:
In the Java programming language, a multidimensional array is simply an array
whose components are themselves arrays.
B,E – : In the Java programming language, a multidimensional array is simply an array
whose components are themselves arrays.
E is wrong? This is a one-dimentional assignment two a two-dimentional array.
A,B
there is no comma between {1,2,3,4} {5,6} in A. A is wrong. Only B is correct.
There is no comma(,) between {1,2,3,4} and {5,6} in A. The A is wrong.
Only B is correct: in D an array variable is used which is not initialized.