Welcome Guest | Sign in | Register
Variables and Loops - Discussion Page For Q.2979 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Variables and Loops > Questions and Answers

Q: class A {
A(String s) {
}
A() {
}
}
1. class B extends A {
2. B() { }
3. B(String s) {
4. super(s);
5. }
6. void test() {
7. // insert code here
8. }
9. }

Which of the below code can be insert at line 7 to make clean
compilation ?
A. A a = new B(); B. A a = new B(5);
C. A a = new A(String s); D. All of the above

Answer and Explanation

Answer:A a = new B();

Explanation:
A a = new B(); is correct because anonymous inner classes are no different from any
other class when it comes to polymorphism.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.