Inheritance
Notes on Inheritance (First set)
- Inherited state and methods are not repeated in subclass.
- Subclass constructor invokes superclass constructor with
super()
"method" to initialize inherited state.
- A redefined method (same signature, new body)
overrides method from superclass; redefined
method is executed instead.
private
: instance variables & methods cannot be
accessed/used directly by the subclass
public
: can be accessed/used by subclass (or anyone)
protected
: accessible to class and
its subclasses, but not to other classes (new keyword)
Alyce Brady, Kalamazoo College