What is the output of the following code snippet: int[][] arr = new int[3][2]; System.out.println(arr.length);?

  • 2
  • 3
  • 6
  • The code will result in a compilation error.
In the given code, arr.length returns the number of rows in the 2D array. Here, arr is declared as a 2D array with 3 rows and 2 columns, so it prints 3, which is the number of rows.
Add your answer
Loading...

Leave a comment

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