GeekInterview.com
Series: Subject:
Question: 36 of 271

difference between data encapsulation vs abstraction

Asked by: Interview Candidate | Asked on: Aug 26th, 2006
Showing Answers 1 - 11 of 11 Answers
mani

Answered On : Aug 28th, 2006

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

  
Login to rate this answer.

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".

Yes  1 User has rated as useful.
  
Login to rate this answer.
Abhi

Answered On : 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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
sabrish

Answered On : 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...

Yes  1 User has rated as useful.
  
Login to rate this answer.
dinu_26

Answered On : Nov 11th, 2008

View all answers by dinu_26

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.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
anjali4788

Answered On : Mar 4th, 2009

View all answers by anjali4788

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

  
Login to rate this answer.
PNVRKPrasad

Answered On : Jul 11th, 2009

View all answers by PNVRKPrasad

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.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
mandeepx81

Answered On : Sep 3rd, 2009

View all answers by mandeepx81

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.

Yes  2 Users have rated as useful.
  
Login to rate this answer.
rajeshspandian

Answered On : Oct 12th, 2009

View all answers by rajeshspandian

Encapsulation is wrapping up the data into a single unit (classes).

Abstraction is something like data Hiding.

Yes  1 User has rated as useful.
  
Login to rate this answer.
henktade

Answered On : Oct 20th, 2010

View all answers by henktade

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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
rajesh.tiet

Answered On : Jan 7th, 2011

View all answers by rajesh.tiet

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

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.