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 , D
‘D’ answer seems odd!
What is the meaning of the word “array”?
‘A’ seems correct except for a space between “array” and “2D” is that a mystyping?
Please let me know what you think.
declare int[] array = {1,2};
Answer is A, B
Answer A was mistyped and should have been written as:
int [] [] array2D = {{0, 1, 2, 4}, {5, 6}};
A y B