What is difference between Abstraction and Encapsulation? Please give some example also because it is always confusing my.
Raghvendra Singh
Select an image from your device to upload
Abstraction meas hiding the complexcity of program i.e. it is the manner how write a program in simplest way.
Encapsulation is, wrapping a data and method into a single unit(Class) i.e. hiding all internal details of an objects to outside.
Data Abstraction: Data Abstraction is nothing but hide the client details,like bike is hide the type of eingine and type of wheels etc.It is provide safty and protection etc.
An abstract data type is a user-defined data type that satisfies the following two conditions:The representation of, and operations on, objects of the type are defined in a single syntactic unitThe representation of objects of the type is hidden from the program units that use these objects, so the only operations possible are those provided in the type's definition
Go through this link .u get examples for all Oops .http://www.dotnetspider.com/resources/18616-OOPS-Concepts-Net-Shake-your.aspx
Abstraction means to show essential details to the client.
Do you know the inner details of the Monitor of your PC? What happen when you switch ON Monitor? Does this matter to you what is happening inside the Monitor? No Right, Important thing for you is weather Monitor is ON or NOT. When you change the gear of your vehicle are you really concern about the inner details of your vehicle engine? No but what matter to you is that Gear must get changed that’s it!! This is abstraction; show only the details which matter to the user.
Encapsulation is hiding non essential details to the client.
The monitor of your pc is wrapped with plastic body and switch is provided for on and off isn’t it ? What will happen if they will give you the monitor without plastic body? Don’t you think so it will be a dangerous enough? If your bike comes with the parts and guide book and let us assume you know how to assemble, do you want to assemble it every day so that you neighbours will come to know the technology? This is encapsulation; hiding the details which are not required by the user gives you safety and protection from overenthusiastic clients.