Multiple choice technology programming languages

Which of the following are legal array declarations.

  1. int i[][];

  2. int i[5][5];

  3. int []i[];

  4. int[][] a;

Reveal answer Fill a bubble to check yourself
A,C,D Correct answer
Explanation

Java array declarations can use brackets on the type, after the variable name, or both. 'int i[][]' (C), 'int[]i[]' (D), and 'int[][] a' (D) are all legal. However, 'int i[5][5]' (B) is illegal because Java doesn't allow size specification in declarations - array sizes are set at initialization, not declaration.