SE450: Overriding: Overriding [10/35] |
Overriding: a non-static method in a subclass has the same name and signature as a non-static method in the superclass.
Intuition: the method implementation in the subclass ``replaces'' the implementation of the method in the superclass.
Example:
class B { public void m() { ... } } class D extends B { public void m() { ... } } B b = new B(); b.m(); // invoke m in class B D d = new D(); d.m(); // invoke m in class D