Hello Friends Pls Explain....
1. Which declaration for 2D array are true ?
a> int a[][] = new int[][]
b> int []a[] = new int[5][]
c> int []a[] = new int[][5]
d> int [][]a = new int[5][]
ans given are : b, d.
If I am not wrong according to me the ans is : a,d.
Pls let me clarify .....
2. What is the result of the following program if it is compiled.
class Continue {
public static void main(
String args[]) {
outer: for(int i=0;i<2;i++) {
for: for (int k=0;k<2;k++) {
if (i==j) break for;
System.out.println(i+ " " +k);
}
}
}
}
Ans given is : 10
11
According to me the code will not compile for two reasons.
1. variable 'j' is not defined .(i.e. int, byte, short..etc)
2. 'for' is the
java keyword and can not be used as label.
Pls Let me sure.
Tejas Nakawala.