up previous next contents
Next: Marking methods and classes Up: Extending Classes Previous: Constructors in extended classes   Contents

Subsections

Overriding methods, hiding fields, and nested classes

Overloading - providing more than one method with the same name but with different signatures. Overriding - replacing a superclass's implementation with your own.

Overriding

  • Signatures must be identical.
  • Return type must be the same.
  • Only accessible non-static methods can be overridden.
  • A subclass can determine whether a parameter in an overridden method is final.

The super keyword

  • Available in all non-static methods of a class.

super.method() - uses the superclass's implementation of method.


up previous next contents
Next: Marking methods and classes Up: Extending Classes Previous: Constructors in extended classes   Contents