Difference between data encapsulation vs abstraction

Showing Answers 1 - 12 of 12 Answers


  • Aug 28th, 2006

Abstraction is achieved through encapsulation..Abstraction solves the problem in the design side while encapsulation is theimplementation.

  Was this answer useful?  Yes

Abstraction is virtual class design.

Before actually defining class, developer will think about what all properties,methods and event will be there in my class.

Whereas,encapsulation is data hiding.

At the time of class defenation,developer will think about which should display to end user and which should not.

In Short Abstraction is "Collection of data" and Encapsulation is "Exposure (or grouping) of data in appropriate access specifier".


  • Feb 20th, 2007

Abstraction means datahideing.That means we use the object wethout knowing the source code of the class.

Encapsulation is a mechanism by which we desigm our class such a way that if  we change our class in fuature, we dont need to change the classes which are depending on our classes.


  • Nov 27th, 2007

Encapsulation is nothing but hiding information also called datahiding...
while abstraction denotes the essential characteristics of an object which differentiates from other kinds of object...


  • Nov 11th, 2008

Abstraction is used for hiding the unwanted information and giving revelant information.

Eg: Three set of customers are going to buy a bike, First one wants information about the style. Second one wants about the milage. Third one wants the cost and brand of the bike.So the salesperson explains about the product which customer needs what. So he hiding some information and giving the revelant information.

Encapsulation is combines one or more information into a component.

Eg: Capsule is mixed with one or more medicine and packed into the tube. so its related and acting in two moducles.


  • Mar 4th, 2009

Abstraction is the representation of data that how we represent it whereas encapsulation is hiding of unnecessary details from user.

  Was this answer useful?  Yes


  • Jul 11th, 2009

Encapsulation and abstraction both solve same problem: Complexity; but in different dimensions.

Abstraction: Hides the implementation details of your methods. Provides a base to variations in the application which can grow over a period of time.

Encapsulation: Hides the private data elements of the class and exposes only the required things to the clients.

Both are powerful; but using abstraction require more skills than encapsulation and bigger applications/products can not survive with out abstraction.


  • Sep 3rd, 2009

It is wrong to call Encapsulation as only data hiding. Though this defination is usually taught in school, but now according to latest OOPs principles its considered incomplete.

According to the book "Design Patterns Explained"

At conceptual level:

Encapsulation means any type of hiding. It can be either data, behaviour, implementation or derived classes or any other thing.

Abstraction means to generalize or conceptualize: to step back from the more concrete to the more conceptual or abstract.

At implementation level:
Encapsulation is achieved by inheritance, aggregation or composition.

Abstraction is represented by using abstract classes to represent a generalized version of set of related classes.


  • Oct 20th, 2010

Encapsulation is data wrapping for the propose of simplifying system design and implementation.

Abstraction is data hiding and categorizing system parts in to components were we deal with them at a higher level or abstract level both for the propose of security, integrity and simplification.

Abstraction and encapsulation are fundamentals of OOPS. If we are to answer what is oops, then we ll say it is an improvement over structured programming, with the help of its four fundamentals, encapsulation, abstraction, inheritance and polymorphism. 

Now consider a large structured code. we apply various rounds of abstraction over it, trying to put code chunks into functions, so that code becomes easy to understand, and the reader peeps inside only those functions which he is interested in. otherwise, name of the function should be enough to represent what the function is doing. 

Then we want to make this code more close to real world. we club similar things together. we convert the code into a beautiful arrangement. where, those functions, which are operating upon common data, are clubbed together. the common data, and the concerned functions, clubbed logically, so that they represent one real world entity together, are called as an object.

So, this way, principles of abstraction and encapsulation take us closer to oops.

Now, if we want to define these two terms, we can say that abstraction is hiding unnecessary details, whereas encapsulation is binding related things together.

Happy Programming :)
-Rajesh Kumar

  Was this answer useful?  Yes