nerdexam
Oracle

1Z0-803 · Question #96

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.. Two-dimensional arrays are structured as arrays containing other arrays, and like all array types in object-oriented languages, they are considered objects that inherit from the base Object class.

Creating and Using Arrays

Question

Which two statements are true for a two-dimensional array?

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
  • 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

(29 responses)
  • A
    83% (24)
  • B
    10% (3)
  • C
    7% (2)

Why each option

Two-dimensional arrays are structured as arrays containing other arrays, and like all array types in object-oriented languages, they are considered objects that inherit from the base `Object` class.

AIt is implemented as an array of the specified element type.Correct

A two-dimensional array is fundamentally an array whose elements are themselves arrays, meaning it is an array of the specified array element type. For instance, in Java, an `int[][]` is an array of `int[]` objects.

BUsing a row by column convention, each row of a two-dimensional array must be of the same

In languages like Java, two-dimensional arrays can be "jagged arrays," where rows are not required to have the same length.

CAt declaration time, the number of elements of the array in each dimension must be specified

For jagged arrays in languages like Java, only the size of the first dimension must be specified at the initial declaration and allocation; subsequent dimensions can be specified later or individually.

DAll methods of the class Object may be invoked on the two-dimensional array.Correct

In Java, all arrays, including multi-dimensional arrays, are objects and implicitly inherit from the `Object` class, allowing all its public and protected methods to be invoked on the array instance. This means methods like `toString()`, `equals()`, and `hashCode()` are available for array objects.

Concept tested: Multi-dimensional array properties and inheritance

Source: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Topics

#two-dimensional arrays#array of arrays#Object class methods

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice