A

Admin • 828.03K Points
Coach

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
  • Correct Answer - Option(C)
  • Views: 8
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
1. new Derived(); statement executes and invoke the non-parametrized constructor of derived class i.e.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.