What is the issue, if any, with the following statement: int[][] arr = new int[][5];?

  • It declares a 2D array with a missing size for the first dimension.
  • It declares a 2D array with a missing size for the second dimension.
  • It declares a 2D array with a size of 5 for both dimensions.
  • It declares a valid 2D array in Java.
The statement is incorrect because when declaring a 2D array, you need to specify the size of both dimensions. In this case, the size for the second dimension is missing (int[][5]). The correct syntax would be something like int[][] arr = new int[3][5];, where 3 is the number of rows, and 5 is the number of columns.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *