What is the output of the following Java program?

Category: JavaWhat is the output of the following Java program?
satya asked 2 years ago

What is the output of the following Java program?
class Person
{
public Person()
{
System.out.println(“Person class constructor called”);
}
}
public class Employee extends Person
{
public Employee()
{
System.out.println(“Employee class constructor called”);
}
public static void main (String args[])
{
Employee e = new Employee();
}
}

1 Answers
Editor">Editor Staff answered 2 years ago

Output
Person class constructor called
Employee class constructor called
Explanation
The super() is implicitly invoked by the compiler if no super() or this() is included explicitly within the derived class constructor. Therefore, in this case, The Person class constructor is
called first and then the Employee class constructor is called.