Test Series - java

Test Number 44/64

Q: An array of arrays in Java is called ___ array.
A. Bidirectional
B.  Combo
C. Multidimensional
D. Multi-value
Solution: no solution
Q: A multidimensional array contains elements of the same data-type in all rows and columns. State TRUE or FALSE.
A. FALSE
B. TRUE
C. none
D. ...
Solution: no solution
Q: An array of dimension N contains __ number of subscripts or brackets?
A. N-1
B. N
C. N+1
D. 10*N
Solution: no solution
Q: An array with two dimensions is called a two-dimensional array in Java. State TRUE or FALSE.
A. TRUE
B. FALSE
C. none
D. ...
Solution: no solution
Q: Row number and Column number in a Multidimensional array start with ___.
A. -1
B. 0
C. 1
D. 2
Solution: no solution
Q: A 4-dimensional array is an array of ___ dimensional arrays.
A. 4
B. 3
C. 2
D. 1
Solution: An N-dimensional array is an array of (N-1) dimensional arrays.
Q: Choose the correct way of initializing a multidimensional array below.
A. int[][] code = {{1,2},{3,4,5}};
B. int[2][] code = {{1,2},{3,4,5}};
C. int[][] code={1,2, 3,4,5};
D. All
Solution: We should not mention the size of any row or column.
Q: What is the output of the Java program with the multidimensional array?
int[][] goats;
goats = new int[3][];
goats[0] = {1,2};
System.out.println(goats[0][1]);
A. 0
B. 1
C. 2
D. Compiler error
Solution: It is lazy initialization.
So, you can not use braces { } to initialize.
Use the keyword new.
goats[0] = new int[2];
goats[0][0] = 1;
goats[0][1]=2;
System.out.println(goats[0][1]);
//Output: 2
Q: State TRUE or FALSE. In a multidimensional array, the number of Columns in each Row can be different.
1
2 3
4 5 6
A. FALSE
B. TRUE
C. none
D. ...
Solution: no solution
Q: While mentioning the array size in a multidimensional array using the new keyword, the left-most script is mandatory. State TRUE or FALSE.
int ary[][];
ary = new int[5][];//first dimension is compulsory.
A. FALSE
B. TRUE
C. none
D. ...
Solution: no solution

You Have Score    /10