Remember styles of inheritance
A class has supertypes: the class it extends, plus any interfaces it implements.
A supertype can have 3 different policies for how the implementation of a method is treated:
- mandatory: create a mandatory implementation, that can't be overridden - a
final method in a superclass.
- default: create a default implementation, that can be overridden - a non-
final method in a superclass, or a default method in a superinterface (JDK 8+).
- none provided: no implementation is provided at all, and a concrete class is forced to provide their own
implementation - an interface method, or an
abstract method.
A class can take these general policies with respect to overriding, in
order of increasing liberality:
- disallow it completely - declare the class as
final.
- allow it, but disallow all overrides - declare all methods as
final. A subclass can add new methods, but
it can't change the existing ones.
- allow it, and permit some overrides - declare some methods as
final, and some as non-final
- require it - declare some methods as
abstract
See Also :