Which class is the immediate superclass of the Container class?
Frame
Component
Public
Super
class test{} class tester extends test{ public static void main(String[] args) { test t1 = new tester(); test t2 = new test(); tester t3 = new tester(); System.out.println( t1 instanceof tester); System.out.println( t2 instanceof tester); System.out.println( t3 instanceof tester); System.out.println( t1 instanceof test); System.out.println( t2 instanceof test); System.out.println( t3 instanceof test); }
True False True True True True
True False False True True True
True False True True True False
True False True True False True
public class Fun { public static void main(String[] args){ int x=0; boolean b=true; String str; str=(b)?"success": (x=0)?"Failure":"Neither"; System.out.println(str); } }
Failure
success
Exception will be thrown
Compilation error
Neither
class Root { int bark=10; public void get(){ System.out.println("Root"); } } public class Tree extends Root{ public void get(){ bark =15; System.out.println("Tree"); } public static void main(String[] args){ Tree t = new Tree(); Root r = new Root(); Root t1= new Tree(); r.get(); t.get(); t1.get(); System.out.println(t.bark); System.out.println(t1.bark); System.out.println(r.bark); } }
Root Tree Tree 15 15 15
Root Tree Tree 10 15 15
Root Tree Root 15 15 10
Root Tree Tree 15 15 10
Root Tree Tree 15 10 10
public class Top { private int i; Top(int i) {this.i=i; } public int getValue(){ return this.i; } } class Bottom{ public static void main(String[] args) { Top tp = new Top(5); String j = Integer.toString(tr.getValue()); tp.i=15; System.out.println( tp.i + j); } }
155
Exception
20
5 5
public class Play { public static void main(String[] args) { int[][] a = {{5,2,4,7}, {9,2}, {3,4}}; int[] b = a[1]; int[][] b1= new int[3][]; int a2 = b[2]; System.out.println(a2); } }
2
4
9
What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println(“TRUE”); } else { System.out.println(“FALSE”); }
TRUE
true
FALSE
Compilation Error
Run time Error
A Vector is declared as follows. What happens if the code tried to add 6 th element to this Vector new vector(5,10)
The element will not be successfully added
ArrayIndexOutOfBounds Exception
The Vector allocates space to accommodate up to 15 elements
Nothing will happen
int x = 2; switch (x) { case 1:System.out.println(“1?); case 2: case 3:System.out.println(“3?); case 4: case 5:System.out.println(“5?); }
No output
3 and 5
1,3 and 5
0
Is sizeof a keyword ?
True
False