New Dump-(a)
1) What is the correct way to declare an array of 10 integers? Object o[10] int foo[10] 2) class foo {
public static void main (String args[]) { int i=0; int j=5; tp : for(;;i++){ for(;;j){ if (i>j) break tp; } } System.out.println(i+""+j); }
} ans : 0,-1
3) 4) 5)
randomn access file – check for mode “rw” Input stream Reader encoding What collection should map implement Map, hashable, sorted map, sorted set and list Ans: map and sorted map what collection should hashtable implement – java.util.map javalava question ans:java
6) 7)
8) class foo { public static void main (String args[]) { Object ob1=new Object(); Object ob2=ob1; if(ob1.equals(ob2)) System.out.println("equal"); }
}
8)
What should you ans: import java.io.PrintWriter;
9)
static string s; class Foo { static String s;
public static void main(String args[]) { System.out.println(“s=”+s); } } ans : “s=null” 10) class foo {
}
void setvar(int a,int b){ setvar(a,b); } void setvar(float a, int b) { this(a,b); }
ans : 2nd opiton wrong. Only constructors can call other constructors 10) question on encapsulation – 11) what can be thrown – throwable, exception, error, runtimeexception (wrong : object, event) 12) implements Runnable X x = new X(); new Thread(x).start(); 13) class foo { public static void main(String args[]) { UnSigned byte b=0; b; System.out.println(b); }
}
ans : compiler error 13) what will stop the execution of thread wait and last choice 14) How do you read a file DataInputStream(new FileInputStream… ……) 15) switch(4) case 4 : j++;…. Case 5: j++;
Case 6: j++; Default: j++;
} Return(j+x); Ans: 8;
16) awt question ans: KeyEvent 17) awt questions ans: Gridbaglayout can span the rows and columns it can occupy (frame with default border layout, menubar can be added only in the top- wrong) 18) button to panel add to north. Button directly to south. Ans:
height of the two buttons will be same. Width of the button in the north will be constant 19) mouse dragged should implement MouseMotionListener 20) public static int main(String args[]) ans : will compile but throw an Runtime Exception 21) class foo{ int a; public static void modify(int a) { a++; } public static void main(String args[]) { modify(a); s.o.pln(a); } } ans: 0 22) class b { public static int method() { } } class a extends b { public static int method() { } public static void main(String args[]) {
}
System.out.println(new b());
} 23) (only concept class name might differ) class base { } class child extends base{ public static void main(String args[]) { base b=new child(); child c= new child(); c=(child)b; s.o.pln(….) } ans: compiles perfectly – prints value of variable insides the child class. 24) (only concept) class base { } class child extends base{ public static void main(string args[]) { base b=new base(); child c= new child(); c=(child) b; … } } ans: compiles but throws a runtime exception 25) Garbage collection After line 7 o=null; 26) Anonymous class cannot have a constructor 27) It cannot implement multiple interfaces 28) Static inner class will not have an instance of the enclosing class
29) 30)
Static inner class can have both static and non static memebers. But it can access only the static members of the enclosing class. Inner class defined inside the method and anonymous innerclasses CANNOT have static members.
---------------------------------------------------------------