Given the code fragment: What is the result?
A.
Null 4
B.
An IllegalArgumentException is thrown at run time
C.
4 Null
D.
4 An ArrayIndexOutOfBoundException is thrown at run time
Given the code fragment: What is the result?
A.
Null 4
B.
An IllegalArgumentException is thrown at run time
C.
4 Null
D.
4 An ArrayIndexOutOfBoundException is thrown at run time
Check:
http://www.aiotestking.com/oracle/what-is-the-result-286/
D
Answer: D
Explanation:
Assuming that the code is write like this:
int[][] array = { { 0 }, { 0, 1 }, { 0, 2, 4 }, { 0, 3, 6, 9 }, { 0, 4, 8, 12, 16 } };
System.out.println(array[4][1]);
System.out.println(array[1][4]);
An ArrayIndexOutOfBoundException is thrown at this point System.out.println(array[1][4]) because the first array element does not have 4 elements in it.
If the code is like the one showed above than we will have a compilation errors since the code syntax is not the correct one.