What will the following program print?
class Test{ //from w ww.ja va 2s. c o m public static void main (String [] args){ int i = 4; int myArray [][][] = new int [i][i = 3][i]; System.out.println( myArray.length + ", " + myArray[0].length+", "+ myArray[0][0].length); } }
Select 1 option
Correct Option is : E
In an array creation expression, there may be one or more dimension expressions, each within brackets.
Each dimension expression is fully evaluated before any part of any dimension expression to its right.
The first dimension is calculated as 4 before the second dimension expression sets 'i' to 3.
If evaluation of a dimension expression completes abruptly, no part of any dimension expression to its right will appear to have been evaluated.