Which of the following Java statements declare and allocate a 2-dimensional array of integers with four rows and five columns.
Show answerHide answer
Correct answer: (D) int array [][] = new int [4][5];
Explanation
In Java, new int[4][5] creates 4 rows and 5 columns. Declarations like int array[4][5] are not valid Java, and [5][4] has the dimensions reversed.