Abstraction and Encapsulation are the two basic features of Object Oriented Programming.
- Abstraction – Refers to the process of exposing only the relevant and essential data to the users without showing unnecessary information. It lets you focus on what the object does, instead of how it does it.
- Encapsulation – Prevents the data from unwanted access by binding of code and data into a single unit.
|Abstraction means to show only what is necessary.||Encapsulation means to hide complexity.|
|Abstraction solves the problem in the design level.||Encapsulation solves the problem in the implementation level.|
|Abstraction is implemented using interface and abstract class.||Encapsulation is implemented using private and protected access modifier.|
|Abstraction is “To represent the essential feature without representing the back ground details.”||Encapsulation means hiding the internal details of an object, i.e. how an object does something.|
|Abstraction provides you a generalized view of your classes or object by providing relevant information.||Encapsulation means hiding details of implementation from outside world so that, when things change nobody gets affected. Encapsulation is also called data hiding.|