Q18
Given:
1 pubic class ArrayTest {
2 public static void main(String[] args{
3 float f1[],f2[];
4 f1 = new float[1];
5 f2 = f1;
6 System.out.println("f2[0] = "+ f2[0]);
7 }
8 }
What is the result?
A It prints f2[0] = 0.0;
B It prints f2[0] = NaN;
C An error at line 5 causes compile to fail.
D An error at line 6 causes compile to fail.
E An error at line 6 causes an exceptation at run time;
Q19 Given:
public class Test {
public int aMethod(){
static int i = 0;
i++;
return i;
}
public static void main(String[] args{
. Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
What is the result?
A 0
B 1
C 2
D Compilation fails.
Q2 Given:
class Super {
public float getNum(){
return 3.0f;
}
}
public class Sub extends Super {
6
}
Which method,placeed at line 6,causes compilation to fail?
A public void getNum(){}
B public void getNum(double d){}
C public float getNum(){return 4.0f;)}
D public double getNum(float d ){return 4.0d;}
Q21 Given:
boolean bool = true;
if(bool = false) {
System.out.println("a");
}else if(bool){
System.out.println("b");
}else if(!bool){
System.out.println("c");
}else{
System.out.println("d");
}
What is true?
A a
B b
C c
D d
E Compilation fails.
Q22
Which statement is true?
A catch(X x) can catch subclasses of X;
B The Error class is a RuntimeException;
C Any statement that can throw an Error must be inclosed in a try block;
D Any statement that can throw an Exception must be inclosed in a try block;
E Any statement that can throw a RuntimeException must be inclosed in a try block; |
|