The IT Certification Resource Center

Featured Deal

Get CompTIA, Cisco, and Microsoft training courses free for a week.
Learn More ❯

Question 22:

What will be the result of executing the following code?

Given that Test1 is a class.

1. Test1[] t1 = new Test1[10];
2. Test1[][] t2 = new Test1[5][];
3. if (t1[0] == null)
4. {
5.    t2[0] = new Test1[10]    
6.    t2[1] = new Test1[10]    
7.    t2[2] = new Test1[10]    
8.    t2[3] = new Test1[10]    
9.    t2[4] = new Test1[10]    
10. }
11. System.out.println(t1[0]);
12. System.out.println(t2[1][0]);

A. The code will not compile because the array t2 is not initialized in an unconditional statement before use.
B. The code will compile but a runtime exception will be thrown at line 12.
C. The code will compile but a runtime exception will be thrown at line 11.
D. None of these.