hi! It is said that u really cannot draw a boundary between abstraction & encapsulation. As per the definition abstraction is selective acceptance. That is u try to find out important properties/behaviour of an real world entity. and keep them as part of ur class to get an object in software domain. that is class attributes & class methods.U keep them together under one class. But now u may want to keep some attributes or methods very private to urself they are very important. So u dont give direct access to them u provide methods to access them. So u provide a wrapper over it.this is encapsulation Its just like a capsule u keep the bitter but important part inside & provide a good interface over it. so that it is handy to use. It has great advantages 1. tomorrow if i keep the wrapper same but change the internal data say add a new medicine inside it. User is not affected. He just has to take the capsule the same way he was taking earlier. See in software domain keeping interface same is very important. 2. Also no one will have direct access to my important data .So it is safe inside. But now somethings i would like to keep private but some behaviour i would like everyone to share. So i do the abstraction again.I find out things that can be shared out & show them outside whereas private things are again private.To achieve this u provide a wrapper (encapsulate it) using access specifiers. so abstraction & encapsulation go hand in hand. e.g.: a common real world entity: Car: Abstraction: Structural attributes of class car) I dont need all 10000 parts to represent car in software domain. So i will minimise my window to only parts that i need. Say stairing acclerator wheels break fuel pump piston Behavioral methods of class car) start move stop fuel injection etc Now all these methods use the attributes to achieve the functionality. But out of these some methods and some parts are internally used by the car & user may not bother @ them.so again do abstraction to find out things that can be directky accesed by user & that which may not be accessed directly. I hope this will clear ur doubt. Warm Regards, meghana.
Abstraction is omitting noisy details to reveal the important stuff.
Encapsulation is nearly anything you say it is ... or at least every expert has a subtly different definition. You'll find emphasis on information hiding in some places, emphasis on "doing one thing well" in others. I tend to talk about those things separately and consider "encapsulation" to fuzzy to even use in conversation.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi