Difference between Abstraction and Encapsulation :-
Abstraction | Encapsulation |
---|---|
Abstraction solves the problem in the design level. | Encapsulation solves the problem in the implementation level. |
Abstraction is used for hiding the unwanted data and giving relevant data. | Encapsulation means hiding the code and data into a single unit to protect the data from outside world. |
Abstraction lets you focus on what the object does instead of how it does it. | Encapsulation means hiding the internal details or mechanics of how an object does something. |
Abstraction- Outer layout, used in terms of design. For Example:- Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number. | Encapsulation- Inner layout, used in terms of implementation. For Example:- Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connect with each other using circuits. |
The easier way to understand Abstraction and encapsulation is as follows:-
Real World Example:-
Take an example of Mobile Phone:-
You have a Mobile Phone, you can dial a number using keypad buttons. Even you don't know how these are working internally. This is called Abstraction. You have the only information that is needed to dial a number. But not its internal working of mobile.
But how the Mobile Phone internally working?, how keypad buttons are connected with internal circuit? is called Encapsulation.
Summary:
"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"
"Information/Data hiding is accomplished by using Modifiers - By keeping the instance variables private or protected."
+ comments + 1 comments
You can watch on YouTube => Click Here
!!!Demo!!! What a fantastic resource that you point out here, happy to see such informative stuff.
Thanks a lot for sharing. I appreciate your hard efforts.
Good luck!
Best 3D Printers:
B9 Printer
B9 3D Printer
B9 Core 550
B9 Creator v1.2
Cheers! !!!Demo!!!
Post a Comment