Encapsulation:
Means putting the data and the function that operates on that data in a single unit(information hiding) .Encapsulation prevents clients from seeing its inside view, where the behavior of the abstraction is implemented.
Encapsulation is the mechanism that binds together code and the data it manipulates,and keeps both safe from outside interference and misuse.in java encapsulation is achieved by making use of access modifiers( keeping variables as private and providing public getters and setters.
Eg:-
automatic transmission of an automobile.
It encapsulates lots of information about the engine, such acceleration, the pitch of the surface , and the position of the shift
lever. Being a user,we have only one method of affecting this complex encapsulation: moving the gear-shift lever.
Inheritance:
Inheritance is the process by which one object acquires the properties of another object.
Eg:-Vehicle->motorized->4wheeled.
Polymorphism:
Polymorphism (from the Greek, meaning “many forms”) is a feature that allows one interface to be used for a general class of actions.
Eg. Car's steering ->one interface many implementations(power or rack and pinion)
Abstraction:
Means hiding the internal details and just exposing the functionality.
Eg:-When we change the gear of a car, we know the gears will be changed without knowing how they are functioning internally.
Abstraction focuses on the outside view of an object (i.e. the interface).
nice article..
ReplyDeletegood one man ..
ReplyDeleteYeh dil maangey more.
~GS
this is common thing i hope everybody knw so plz can u elobrate the encapuslation with real time exp.
ReplyDeleteany way keep it up.
very easy way of understanding
ReplyDeleteSimple and humple,very good example
ReplyDelete