DEV Community

Discussion on: Constructor Behavior in Inheritance

Collapse
 
cicirello profile image
Vincent A. Cicirello

Even in that case, it doesn't inherit the default no-parameter constructor. In Java, constructors are never inherited. There are 2 things going on in that case. If a class doesn't explicitly define a constructor, the Java compiler generates a default constructor for you that simply calls super(). The second thing is that if you do define a constructor but don't explicitly call a superclass constructor, the Java compiler inserts a call to super() in the bytecode that it generates.