Prévia do material em texto
Certified Java Programmer Mock Exam 84
public void y(int y) {this.y = y;}
public abstract int math();
}
class B {
static A a1 = new A(2,1) {
public A(int i1, int i2) {x(i1);y(i2);};
public int math() {return x()+y();}
};
public static void main(String[] args) {
System.out.print(a1.math());
}
}
What is the result of attempting to compile and run the program?
a. Prints: 8
b. Prints: 3122
c. Compile-time error.
d. Run-time error.
e. None of the Above.
Question 2
abstract class A { // 1
abstract final void m1(); // 2
abstract final class B {} // 3
class C extends B {} // 4
}
Compiler errors are generated at which of the following lines?
a. 1
b. 2
c. 3
d. 4
e. None of the Above
Question 3
Which of the following are class modifiers? Select all that are applicable to a top-level class and all that are applicable to a nested class. It is not
required that a modifier be applicable to both.
a. abstract
b. extends
c. final
d. implements
e. private
f. protected
g. public
h. static
i. synchronized
j. transient
k. volatile
l. strictfp
m. None of the above.
Question 4
Which of the follow are true statements.
a. A nested class is any class that is declared within the body of another class or interface.
b. A nested class can not be declared within the body of an interface declaration.
c. A top level class is a class this is not a nested class.
d. An inner class is a nested class that is not static.
e. A nested class can not be declared static.
f. A named class is any class that is not anonymous.
g. None of the above.
Question 5
Which of the following modifiers can be applied to a member class?
a. public
b. protected
c. private
d. abstract
e. static
f. final
g. strictfp
h. None of the above.
Question 6
Which of the follow are true statements.
a. An anonymous class can be declared abstract.
b. An incompletely implemented class must be declared abstract.
c. A local class can be declared abstract.
d. An abstract class can be instantiated.
e. An abstact class is implicitly final.
f. An abstact class must declare at least one abstract method.
g. An abstact class can not extend a concrete class.