Encapsulation and abstraction

Encapsulation and abstraction is a mechanism that lets our program to hide unwanted code within a capsule and shows only essential features of an object.

Encapsulation is used to hide its members from outside class or interface, whereas abstraction is used to show only essential features.

We can think in other way that encapsulation implements abstraction.

So the difference we can say that abstraction is the modeling term and Encapsulation is the implementation. We use 5 types of modifier to encapsulate data.

Tricky question

  1. Different between Encapsulation and data hiding.

results matching ""

    No results matching ""