Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Homework
hii friends
 
i want to know the main diff between abstraction and encapsulation...
 
Edit: Added the homework tag as this question is a favourite of university lecturers wanting to scare their students
Posted 23-Jan-11 5:44am
Edited 23-Jan-11 7:51am
Aescleal30.2K
v2
Comments
SAKryukov at 23-Jan-11 11:54am
   
Incorrect question.
Everyone should realize that the question in the form "What is the difference between..." can be incorrect and it is most likely incorrect. Examples: "What's the difference between apple and Apple?", "What's the difference between apply and cognitive dissonance?". This question is exactly like the last one.
SAKryukov at 23-Jan-11 11:55am
   
Is it interview question? I would not even try to answer...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 10

Abstraction is like going to interviews: you know the general procedure, and that you're going to be asked questions. But you don't know who will ask the questions and what the results will be.
 
Encapsulation is when an interviewer asks you a question and has the answer in his head, but doesn't give it away: you can't access the answer directly, but you can interact with it by providing an answer and have the interviewer judge whether it matches his expected answer or not.
 
[edit]just forget it - I only now realized how old that question was .... :-/ [/edit]
  Permalink  
v2
Comments
Emre Ataseven at 20-May-14 2:54am
   
Good analogy :)
Legor at 20-May-14 3:34am
   
Why answer a 3 year old question?
Stefan_Lang at 20-May-14 3:38am
   
As you can see by my edit I didn't realize that at the time of posting. At that time the OP was shown as current in the overview - but only because of the newly posted Solution 9. I didn't bother to check the actual date of the OP...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You might be very surprised to find that you are not the first person to ask this question.
 
I just googled for difference abstraction encapsulation and I got over 600,000 hits. The first four pages were all people asking this very question, at which point I got bored, so there could have been more.
 
Have a go for yourself and follow any reference material pointed to by the answerers.
 
You really should have done this before asking here, you know.
  Permalink  
Comments
Manfred R. Bihy at 23-Jan-11 12:21pm
   
Reading does seem to be unpopular nowadays!
Compensated! 5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Did you consider using google, reading your textbooks or asking your teacher for help with your homework ?
 
Here[^].
  Permalink  
Comments
Manfred R. Bihy at 23-Jan-11 12:21pm
   
Reading does seem to be unpopular nowadays!
Compensated! 5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Encapsulation is hiding implementation details (making a field private for example) and abstraction is using "something" without beeing aware of how it works (when you start the engine of your care you don't care how it works, it just starts, just like when you add a element to a list and you are not thinking how it's implemented).
I hope my English is good enough to make this clear. If not, I can try it again.
  Permalink  
Comments
Manfred R. Bihy at 23-Jan-11 12:21pm
   
Reading does seem to be unpopular nowadays!
Compensated! 5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You might want to get a book on OOPS and go through it.
  Permalink  
Comments
Manfred R. Bihy at 23-Jan-11 12:21pm
   
Reading does seem to be unpopular nowadays!
Compensated! 5+
Abhinav S at 14-Oct-13 22:57pm
   
Thank you Manfred.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Once you've googled those terms, as CG suggested, you'll still find that things are still a little hazy. It's alright though. One thing a lot of newbie programmers don't get is that unlike coding, which is pretty much an exact science, software design theory is not an exact science. It's like doing a math class for an hour and then attending a class on theoretical long term economics.
 
I've been programming for 2 decades now, and yet if someone asked me this sort of question my answer would probably not be very interesting, impressive, or enlightening. In fact I suspect I'll promptly flunk the interview!
  Permalink  
Comments
Christian Graus at 23-Jan-11 10:54am
   
On the other hand I aced an interview in my early days by suggesting that code reuse was a furphy that almost never happens in real life !!!
Nishant Sivakumar at 23-Jan-11 10:55am
   
LOL. That must have been an interesting job!
Stefan_Lang at 20-May-14 2:34am
   
Sadly, that does match my experience.
Manfred R. Bihy at 23-Jan-11 12:21pm
   
Reading does seem to be unpopular nowadays!
Compensated! 5+
Nishant Sivakumar at 23-Jan-11 18:19pm
   
Thanks.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Abstraction is a concept.
Encapsulation is a tool.
  Permalink  
Comments
fgoldenstein at 26-Jan-11 6:26am
   
Maybe you use a tool (Visual Studio) to encapsulate a field but encapsulation is a concept. It's hiding implementation details (you make a field private).
Emilio Garavaglia at 26-Jan-11 7:43am
   
Gee, there is not only a physical and a logical world. There are different level of abstractions. Encapsulation is "(one of) the tool you use to conceptualize an abstraction into an higher abstraction layer". Encapsulation is not only something related to "coding" and programming is not only just "coding".
 
I was simply tried to synthesize these concept into two rows. They cannot be accurate, but at least a few more mental elasticity from a "professor" is something I have to expect!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

To answer this you have to do three things:
 
- define what abstraction means in OO terms
- define what encapsulation means in OO terms
- compare and contrast the two of them
 
Encapsulation is a real snake in the grass as most software engineers conflate it with information hiding (another term that's worth looking up for your assignment as it's a form of abstraction) when it's something completely different (it's about bundling, not hiding). However even if you come up with definitions for the terms that aren't quite what your interviewer/examiner wants provided you define them well enough and can cite references for them (in an accademic environment this is particularly important) that shouldn't hinder you getting through.
 
Cheers,
 
Ash
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 8

Abstraction is hiding Complexity (Ex:Garbage Collection)
Encapsulation is just a wrapper over Things(Ex:Web Service Contract/Interface)
  Permalink  
Comments
Richard MacCutchan at 14-Oct-13 7:11am
   
Why are you responding to a question that is nearly three years old? The person who posted this has already graduated or given up on this course.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 11

Abstraction is a thought process of designing an entity by identifying the relevant qualities and behaviors it should have.
- It emphasizes on essential features of an entity rather than its details which means it is more about what the entity will do rather than how it will do.
- It is used when you know something needs to be there but not sure how exactly it should look like.
- It is an earlier step of encapsulation.
 
Encapsulation is the actual implementation of Abstraction to create the final entity.
- It involves in grouping of data and functionality in a single unit called class.
- It simplifies the functionality by hiding the complexity. It hides the internal details of how an entity does anything and just provide its output.
- It guarantees that the encapsulated data and methods are not accessed by any one outside the encapsulated entity, by using access modifiers.
  Permalink  
v3
Comments
Legor at 12-Sep-14 4:10am
   
Dont answer posts which are 3 years old
NK Sharma at 12-Sep-14 4:43am
   
Is there any such policy on CodeProject?? sorry I was not aware of it, I just gave my contribution so that some may got clear idea on the topic.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 535
1 OriginalGriff 275
2 Shweta N Mishra 244
3 BillWoodruff 235
4 Deepu S Nair 230
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,818
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,755


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 11 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100