Saturday 25 April 2020

What is Inheritance & Polymorphism in Software Engineering?

 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. 
  1. Draw command can have different implementation for circle, line, rectangle. 
  2. In Lab WhoAreYou() method of Car, Truck and Bus classes 

No comments:

Post a Comment