What is the result of running the following program?
1: package mypkg; 2: public class Main { 3: static int[][] v; 4: //from ww w . ja v a 2s.c o m 5: public static void main(String args[]) { 6: v[3][3] = 6; 7: Object[] obj = v; 8: obj[3] = 'X'; 9: System.out.println(v[3][3]); 10: } 11: }
D.
The instance and class variables are initialized to null.
Line 6 throws a NullPointerException.
If the array was declared, the answer would be E because the code would throw an ArrayStoreException on line 8.