Here are some real Exam Questions for OCAJP 7
What will the following code print when compiled and run?
What will the following code print when compiled and run?
class ABCD{
int x = 10;
static int y = 20;
}
class MNOP extends ABCD{
int x = 30;
static int y = 40;
}
public class TestClass {
public static void main(String[] args) {
System.out.println(new MNOP().x+", "+new MNOP().y);
}
}
10,40
30,20
10,20
30,40
20,30
compilation error
-----------------------------------------------------------------------
Which of these array declarations and instantiations are legal?
int[ ] a[ ] = new int [5][4] ; int a[ ][ ] = new int [5][4] ; int a[ ][ ] = new int [ ][4] ; int[ ] a[ ] = new int[4][ ] ; int[ ][ ] a = new int[5][4] ;