What is Difference between Abstraction and Encapsulation?

 

1

Abstraction is the process or method of gaining the information

While encapsulation is the process or method to contain the information

2

Abstraction is detail hiding(implementation hiding)

Encapsulation is data hiding(information hiding)

3

Data abstraction deals with exposing the interface to the user and hiding the details of implementation

Encapsulation groups together  data and methods that act upon the data

4

In abstraction problems are solved at the design or interface level

While encapsulation problems are solved at the implementation level

5

Abstraction is the method of hiding the unwanted information

Whereas encapsulation is a method to hide the data in a single entity or unit along with a method to protect information  from outside

6

We can implement abstraction using abstract class and interfaces

Whereas encapsulation can be implemented using by access modifier/specifiers private ,protected and public

7

In abstraction  implementation complexities are hidden using abstract classes and interfaces

While in encapsulation the data is hidden using methods of getters and setters

8

The object that help to perform abstraction are encapsulated

Whereas the objects that result in encapsulation need  not be abstracted

 

Comments

Blogs