1.

What Is The Difference Between Inheritance And Encapsulation?

Answer»

Inheritance is an object oriented concept which creates a parent-child RELATIONSHIP. It is one of the ways to reuse the code written for parent class but it ALSO forms the BASIS of Polymorphism. On the other hand, Encapsulation is an object oriented concept which is used to hide the internal details of a class e.g. HashMap encapsulate how to STORE elements and how to calculate hash values.

Inheritance is an object oriented concept which creates a parent-child relationship. It is one of the ways to reuse the code written for parent class but it also forms the basis of Polymorphism. On the other hand, Encapsulation is an object oriented concept which is used to hide the internal details of a class e.g. HashMap encapsulate how to store elements and how to calculate hash values.



Discussion

No Comment Found