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.
Loading...
Related Quiz
- The expression a != b returns true if a is ______ b.
- The ________ method of the String class returns the index within this string of the first occurrence of the specified character, starting the search at the specified index.
- If you are working on a highly concurrent system that uses many synchronized methods, and you notice that the application is facing performance issues, how might you optimize the application while maintaining thread safety?
- What does the >>> operator do in Java?
- The ________ method of URL class provides the port number of the URL.