1Z0-808 · Question #80
Which two statements are true for a two-dimensional array?
The correct answer is A. It is implemented as an array of the specified element type. D. All methods of the class Object may be invoked on the two-dimensional array. In Java, a two-dimensional array is fundamentally an array of arrays - meaning int[][] is literally an array whose elements are int[] objects, confirming A. Since arrays are objects in Java and all objects inherit from java.lang.Object, methods like equals(), hashCode(), and…
Question
Options
- AIt is implemented as an array of the specified element type.
- BUsing a row by column convention, each row of a two-dimensional array must be of the same size
- CAt declaration time, the number of elements of the array in each dimension must be specified
- DAll methods of the class Object may be invoked on the two-dimensional array.
How the community answered
(60 responses)- A88% (53)
- B8% (5)
- C3% (2)
Explanation
In Java, a two-dimensional array is fundamentally an array of arrays - meaning int[][] is literally an array whose elements are int[] objects, confirming A. Since arrays are objects in Java and all objects inherit from java.lang.Object, methods like equals(), hashCode(), and toString() are always available on any array, making D correct. B is wrong because Java supports jagged arrays - each row is an independently allocated array and can have a different length (e.g., arr[0] can have 3 elements while arr[1] has 5). C is wrong because dimensions are not required at declaration time; you can write int[][] arr; or new int[3][] and specify (or skip) inner dimensions later.
Memory tip: Think of a 2D array as a "folder of lists" - the folder is an object (so Object methods apply), and each list inside can be a different length (no forced uniform rows). Declaration just names the folder; you fill it in later.
Topics
Community Discussion
No community discussion yet for this question.