Polymorphism & inheritance
Design Principles:* A derived class should have an ' is-a, plus ' relationship to the superclass.
- The derived class is an instance of the superclass, plus same additional attributed & methods.
* Push common attributes & methods as high as possible in the hierarchy.
*If the derived class needs to manipulate attributes in superclass, use the methods of the superclass where possible.
Java Keywords:
'super' refers to the immediate superclass
'this' refers to the current class
No comments:
Post a Comment