Abstraction |
Encapsulation |
Abstraction is the process or method of gaining the information. | Encapsulation is the process or method to contain the information. |
In abstraction, problems are solved at the design or interface level. | Problems are solved at the implementation level. |
Abstraction is the method of hiding the unwanted information. | Encapsulation is a method to hide the data in a single entity or unit along with a method to protect information from outside. |
We can implement abstraction using abstract class and interfaces. | Whereas encapsulation can be implemented using by access modifier i.e. private, protected and public. |
In abstraction, implementation complexities are hidden using
| The data is hidden using methods of getters and setters.. |
The objects that help to perform abstraction are encapsulated. | The objects that result in encapsulation need not be abstracted. |
Abstraction provides access to specific part of data. | Encapsulation hides data and the user can not access same directly (data hiding. |
Abstraction focus is on “what” should be done. | Encapsulation focus is on “How” it should be done. |