What is the output of the following Java program A03?

Description:

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();  
    }  
}  

Solution:

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.

0 answers