What will be the result of attempting to run the following program?
public class Main { public static void main(String[] args) { String[][][] arr = {/*from www. ja va 2 s .co m*/ { {}, null }, { { "1", "2" }, { "1", null, "3" } }, {}, { { "1", null } } }; System.out.println(arr.length + arr[1][2].length); } }
Select the one correct answer.
(a)
The expression arr.length will evaluate to 4.
The expression arr[1] will access the element { { "1", "2" }, { "1", null, "3" } }, and arr[1][2] will try to access the third sub-element of this element.
This produces an ArrayIndexOutOfBoundsException, since the element has only two sub-elements.