OCA Java SE 8 Core Java APIs - OCA Mock Question Core Java APIs 4-2


Which of these array declarations is not legal? (Choose all that apply)

  1. int[][] scores = new int[15][];
  2. Object[][][] cubbies = new Object[13][10][51];
  3. java.util.Date[] dates[] = new java.util.Date[12][];
  4. int[][] types = new int[];
  5. int[][] java = new int[][];
  6. String myArray[] = new myArray[61];


D, E, F.


Option C uses the variable name as if it were a type.

Options E and F don't specify any size.

Although it is legal to leave out the size for later dimensions of a multidimensional array, the first one is required. Option A declares a legal 2D array.

Option B declares a legal 3D array. Option D declares a legal 2D array.