Q12
Given:
public class Test{
public static void aMethod() throws Exception {
try{
throw new Exception();
}finally{
System.out.println("finally");
}
}
public static void main(String[] args){
try{
aMethod();
}catch(Exception e){
System.out.println("exception");
}
System.out.println("finished");
}
}
What is the result?
A finally
B exception
finished
C finally
exception
finished
D Compilation fails.
Q13
Given:
1 public interface foo{
2 int k=4;
3 }
Which three are equivalent to line 2?(choose three)
A final int k = 4;
B public int k = 4;
C static int k = 4;
D abstract int k = 4;
E volatile int k = 4;
F protected int k = 4;
Q14
Given:
1 package test1;
2 public class Test1{
3 static int x = 42;
4 }
1 package test2;
2 public class Test2 extends test1.Test1 {
3 public static void main(String[] args){
4 System.out.println("x="+x);
5 }
6 }
What is true?
A x = 0;
B x = 42;
C Compilation fails because of an error in line 2 of class Test2.
D Compilation fails because of an error in line 3 of class Test1.
E Compilation fails because of an error in line 4 of class Test2.
Q15
Given:
class A {
protected int method(int a,int b){return 0;}
}
Which two are valid in a class that extends class A?(choose two)
A public int method(int a ,int b){return 0;}
B private int method(int a ,int b){return 0;}
C private int method(int a ,long b){return 0;}
D public short method(int a ,int b){return 0;}
E static protected int method(int a ,int b){return 0;}
Q16
Given:
public class Delta {
static boolean foo(char c) {
System.out.println(c);
return true;
}
public static void main(String[] args) {
int i = 0;
for (foo('A'); foo('B')&(i<2);foo('C')) {
i++;
foo('D');
}
}
}
What is the result?
A ABDCBDCB
B ABCDABCD
C Compilation fails.
D An exception is thrown at runtime. |
|