We use super() to call the constructor of parent class.
we know that every method have:
- some prototype (i.e.
modifier returnType methodName (arguments){}), - Its own definition, and
- In which class it is present.
So, I want to know only that in which class super() is present and what its prototype.
class ParentClass
{
ParentClass()
{
System.out.println("parent class constructor");
}
}
public class ChildClass extends ParentClass
{
ChildClass()
{
super();
}
public static void main(String[] a)
{
ChildClass cc = new ChildClass();
}
}
Output parent class constructor
super() is not present in our class and Object class then how constructor internally call the super()?