<<< Using UML to Model classes | Index | Error handling: Java Exceptions >>> |
The constructor of super class (a base, a parent class) is invoked when object inherits from the parent class.
When instance of an object is allocated by new keyword, the following steps occur:
Constructor of the Parent is invoked.
If no explicit call to a parent constructor of the super class is provided by the programmer, the default constructor of the super class is invoked automatically.
public class GasGiant extends Planet { public GasGiant() { // Explicit call to a parent constructor: super(); } }
Each attribute of the object is initialized.
The rest of the constructor code is executed.
<<< Using UML to Model classes | Index | Error handling: Java Exceptions >>> |