1.

What is the difference between polymorphism and inheritance though both are used for reusability of code?

Answer»

Polymorphism:

  • Reusability of code is implemented through functions (or) methods.
  • Polymorphism is the ability of a function to respond differently to different message.
  • Polymorphism is achieved through overloading. 

Inheritance:

  • Reusability of code is implemented through classes. 
  • Inheritance is the process of creating derived classes from the base class or classes.
  • Inheritance is achieved by various types of inheritances namely single, multiple, multilevel, hybrid and hierarchical inheritances.


Discussion

No Comment Found