A

Admin • 802.91K Points
Coach

Q. What is the expected output?
class Animal {
Animal() {
System.out.println("Animal");
}
}
class Wild extends Animal{
Wild() {
System.out.println("Wild");
super();
}
}
public class Test {
public static void main(String args[]) {
Wild wild = new Wild();
}
}

  • (A) Animal Wild
  • (B) Wild Animal
  • (C) Runtime Exception
  • (D) Compilation Error
  • Correct Answer - Option(D)
  • Views: 7
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
super() call must be the first statement in a constructor.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.