Inheritance
- – Mechanism to create new objects (child objects) based on old ones
(parent object). New objects inherit the qualities of its old object.
- – E.g.
• Parent Class: Mammals
• Child Class: Human, Cat, Dog etc.
- – Ease of maintenance
• If mammals became cold-blooded only change Mammals property
•
Polymorphism
- – Dictionay: Occurrences of different forms, stages, or types
- – Having many forms or implementation of a particular functionality
- – Also exist in real word like inheritance
- – E.g.
- Draw command can have different implementation for circle, line, rectangle.
- In Lab WhoAreYou() method of Car, Truck and Bus classes
No comments:
Post a Comment