Difference Between Abstraction and Encapsulation

What is Abstraction?

Abstraction is an OOP concept that helps in concealing the relevant data and shows only required data that is useful for the user. It hides background features and highlights key data points to reduce complexity and improve clarity for productivity.

An example of Abstraction can be, When you are assigned with the task, that is to create an online course admission portal, and the data fields provided are (name, age, current occupation, college name, payment method, Marital status, sibling’s name, vehicle number) after looking at the data fields you can interpret that some data files are not required as (vehicle number or sibling’s name) for the enrolment purpose.

So, we need to be particular and select only the required data i.e., only the required field names and this makes a proper example of abstraction in OOP because we have abandoned irrelevant data and selected only required data from the data provided.

In Abstraction, security, and privacy of data are maintained in only required data is shown for the user. Abstraction is used for initial problem solving for the design level. The only disadvantage of abstraction is it focuses on what class instance can do you rather than execution of the class.

What is Encapsulation?

Encapsulation is one of the features of the OOP concept which helps in binding up data with changeable or variable members. Encapsulation is considered an important feature in OOP because it prevents accessing of data from outsourcing or outside of the class as it is a very important feature for the security of data.

Encapsulation takes care of and addresses issues that arise at the execution level, and controls data maintenance and security. The relation can be executed by using access modifiers like public, private, and protected.

An example for Encapsulation can be a calculator, as we can understand its interface from the outside but we don’t know how it works from inside or how it functioned. We only know that when we press 1+1 we will get the correct answer.

Difference Between Abstraction and Encapsulation

  1. Abstraction is an OOP fundamental concept used in concealing irrelevant data and showing only required data used for the user whereas Encapsulation is binding of data member with another variable member.
  2. Abstraction solves problems at the design level where is encapsulation is used at the execution level.
  3. Abstraction only focuses on what a class instance can do instead of executing the class, Encapsulation on the other hand facilitates binding data and focuses on the execution process.
  4. Abstraction can be executed by using different Java interfaces and abstract classes where is, Encapsulationation can be executed using an access modifier that is privacy protected and public.
  5. The objects are encapsulated in Abstraction whereas objects are not needed to be abstract, which results in Encapsulation.

Comparison Between Abstraction and Encapsulation

DefinitionAbstraction is a process of concealing relevant data and showing only required data. Encapsulation is the binding of data members with changeable or variable members.
PhaseAbstraction is a design-level process.Encapsulation is an important and execution-level process.
Pivotal Capability Abstraction focuses on what class instance can do, rather than execution of class. Encapsulation promotes and binds data and also has the command of maintaining the security of the data.
UseAbstraction solves problems that arise at the beginning of the design phase. Encapsulation solves the problem of the execution phase.
ImplementationAbstraction can be executed using the different interface and abstract classes. Encapsulation can be executed by using access modifiers like public-private and protected.


  1. https://dl.acm.org/doi/pdf/10.1145/948415.948418
  2. https://link.springer.com/content/pdf/10.1007/978-1-4471-0115-4_7.pdf