Single Choice Not Set

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 ?

ID: #2264 Inheritance in Java MCQ 1,310 views
Question Info
#2264Q ID
Not SetDifficulty
Inheritance in Java MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A A a = new B();
  • B A a = new B(5);
  • C A a = new A(String s);
  • D All of the above
Correct Answer

Explanation

A a = new B();

Share This Question

Challenge a friend or share with your study group.