Abstraction
Abstraction allows us to represent the complex real world in the simplest manner. It is the process of identifying the relevant qualities and behaviors an object should possess, in other words representing the necessary feature without representing the background details. Abstraction is a process of hiding the work style of an object and showing only the information which are required to understand the object. Abstraction means putting all the variables and methods in a class that are necessary.
Encapsulation
It is a process of hiding all the internal details of an object from the outside real world. The word Encapsulation is like Enclosing into the capsule. It restricts the client from seeing its internal view where the behavior of the abstraction is implemented. In Encapsulation, generally to hides data making it private and exposes public property to access those data from the outer world. Encapsulation is a method for protecting data from unwanted access or alteration. Encapsulation is the mechanism by which Abstraction is implemented.
Difference between Abstraction and Encapsulation
Abstraction is a process. It is the act of identifying the relevant qualities and behaviors an object should possess. Encapsulation is the mechanism by which the abstraction is implemented.
| Abstraction | Encapsulation |
| Abstraction solves the problem at the design level. | Encapsulation solves the problem in the implementation level. |
| Abstraction is used for hiding unwanted data and giving only relevant data. | Encapsulation is hiding the code and data into a single unit to protect the data from the outer world. |
| Abstraction is set to focus on the object instead of how it does it. | Encapsulation means hiding the internal details or mechanics of how an object does something. |
| Abstraction is the outer layout in terms of design. For Example: the outer Look of an iPhone, is like it has a display screen. | Encapsulation is the inner layout in terms of implementation. For Example: - Inner Implementation detail of an iPhone, how Display Screen are connected with each other using circuits. |

praveen veluthurlaPosted Dec 7, 2019, 6:45 AM
How to implement abstraction and encapsulation please give me answer
praveen veluthurlaPosted Dec 7, 2019, 6:44 AM
How to implement abstraction and encapsulation plz give me answer sir
Ganesh BhadanePosted Mar 15, 2019, 5:43 AM
Thanks...!
Code AlonePosted Dec 2, 2018, 4:42 AM
Good to have this in bookmark. Kindly include Shiv Ratan Kumar comment in this Jignesh Trivedi Sir
rupesh malviyaPosted Sep 7, 2018, 3:55 AM
Nice explain sir...
Hadshana KamalanathanPosted Aug 16, 2018, 1:03 AM
Nice one..
Shiv Ratan KumarPosted Jun 27, 2018, 5:17 AM
Abstraction is code level and Encapsulation is for application level. Application is ready to use we know only button level, data etc but we don't know internal functionality of particular application that is called Encapsulation.but in the code like when we are creating any dll that time who will use dll for that user that is called Abstraction..
Nilufar ParveenPosted Dec 15, 2017, 4:03 AM
Well, that was very useful.
Sujeet SumanPosted Oct 19, 2015, 6:36 AM
Nice Article.................
Pankaj Kumar ChoudharyPosted Jul 3, 2015, 9:15 PM
Nice Explain Sir.............
Upendra Pratap ShahiPosted Jul 3, 2015, 8:35 AM
nice demonstration sir..
Khargesh RajputPosted May 29, 2015, 7:39 AM
nice examples sir
RS PrajapatiPosted Apr 17, 2015, 6:46 AM
"Encapsulation is accomplished by using Class. - Keeping data and methods that accesses that data into a single unit" "Abstraction is accomplished by using Interface. - Just giving the abstract information about what it can do without specifying the back ground details"
Sharad GuptaPosted Jan 17, 2015, 4:14 AM
very good way.....to explain Abstraction and Encapsulation, it has closed many doubt of my mind.
vikas kumarPosted Oct 18, 2013, 3:56 PM
nice
ankit patelPosted Apr 8, 2013, 4:30 AM
awesome