SE450: Java: Extending Classes [10/41] Previous pageContentsNext page

All classes that are not declared final can be extended in Java

The implementation of all methods that are not declared final can be overridden

The initialization of an extended class has two phases:

  1. The initialization of fields inherited from the superclass
  2. The initialization of fields declared in the extended class

The field initialization is done by the constructor (or initialization block) of each class. The constructors are called up the chain. The default super() constructor is called by default. If it is not implemented in the superclass, a compile error will result. Different constructors may be called, ex. super(param1, param2), but the call to the superclasses constructor must the the first statement in the constructor

Previous pageContentsNext page