Q. What is the result of compiling and running the following code?
class Base{
public Base(){
System.out.print("Base");
}
}
public class Derived extends Base{
public Derived(){
this("Examveda");
System.out.print("Derived");
}
public Derived(String s){
System.out.print(s);
}
public static void main(String[] args){
new Derived();
}
}

  • (A) ExamvedaDerived
  • (B) ExamvedaBaseDerived
  • (C) BaseExamvedaDerived
  • (D) BaseExamvedaDerived D. ExamvedaDerivedBase
πŸ’¬ Discuss
βœ… Correct Answer: (C) BaseExamvedaDerived
Explanation: 1. new Derived(); statement executes and invoke the non-parametrized constructor of derived class i.e.
Explanation by: Ram Avtar Sharma
1. new Derived(); statement executes and invoke the non-parametrized constructor of derived class i.e.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
115
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ram Avtar Sharma
Publisher
πŸ“ˆ
93%
Success Rate