The following example shows how to call constructor of parent class. Calling the constructor for the superclass must be the first statement in the body of a constructor.
public class ClassSuper {
public ClassSuper(){
System.out.println("Constructor of ClassSuper called.");
}
}
public class ClassA extends ClassSuper{
public ClassA(){
super();
System.out.println("Constructor without parameter.");
}
public static void main(String[] str)
{
ClassA obj = new ClassA();
}
}
Output:
Constructor of ClassSuper called.
Constructor without parameter.