Overriding Methods
-
To override a method, a subclass of the class that originally declared the method must declare a method with the same name, return type (or a subclass of that return type), and same parameter list.
-
When the method is invoked on an instance of the subclass, the new method is called rather than the original method.
-
The overridden method can be invoked using the super variable.
-
Super can be used to refer to instance variables in the superclass as well.
|