Q14
Given the code fragment:
public static void main(String[] args)
{
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]);
What is the result?
A. Null
B. Null
C. An IllegalArgumentException is thrown at
run time
D. An ArrayIndexOutOfBoundException is thrown at run
time
Il risultato è un' eccezione java.lang.ArrayIndexOutOfBoundsException quando si prova a recuperare l'elemento (1,4) perchè l'array 1 non ha l'elemento 4 (arriva fino all'elemento 1).
Nessun commento:
Posta un commento