nerdexam
Oracle

1Z0-803 · Question #13

Which two are valid declarations of a two-dimensional array?

The correct answer is A. int[][] array2D; D. int[] array2D[];. int[][] array2D; is the standard convention to declare a 2-dimensional integer array. int[] array2D[]; works as well, but it is not recommended. Incorrect answers: int[2][2] array2D; The size of the array cannot be defined this way. int array2D[]; is good definition of a one-dime

Creating and Using Arrays

Question

Which two are valid declarations of a two-dimensional array?

Options

  • Aint[][] array2D;
  • Bint[2][2] array2D;
  • Cint array2D[];
  • Dint[] array2D[];
  • Eint[][] array2D[];

How the community answered

(16 responses)
  • A
    88% (14)
  • C
    6% (1)
  • E
    6% (1)

Explanation

int[][] array2D; is the standard convention to declare a 2-dimensional integer array. int[] array2D[]; works as well, but it is not recommended. Incorrect answers: int[2][2] array2D; The size of the array cannot be defined this way. int array2D[]; is good definition of a one-dimensional array. int[] []array2D[];is good definition of a three-dimensional array.

Topics

#array declaration#multidimensional arrays#array syntax

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice