Dereferencing a Null 2D Array Row
What is the result when the following code is executed?
public class NullRow {
public static void main(String[] args) {
int[][] arr = new int[2][];
arr[0] = new int[]{1, 2};
arr[1] = null;
System.out.println(arr[1].length);
}
}
A
0
B
2
C
NullPointerException at runtime
D
Compilation error
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | y.seong2027 | 1 | 1 | 0m 23s | 77 |
| #3 | busemagngr | 0 | 1 | 1h 00m | -3,610 |
Items per page:
10
1 – 3 of 3
