Java Object oriented programming concepts with real time examples
OOPS Concepts are mainly 4
1.Abstraction
2.Encapsulation
3.Inheritance
4.Polymorphism
Abstraction:-Hiding non-essential features and showing the
essential features
(or)
Hiding unnecessary data from the users details,is called
abstraction.
Real Time example:1.TV Remote Button
in that number format and power buttons and other buttons
there.just we are seeing the buttons,we don't see the
button circuits.i.e buttons circuits and wires all are
hidden.so i think its good example.
Encapsulation:It is a process of binding or wrapping the data and the
codes that operates on the data into a single entity. This
keeps the data safe from outside interface and misuse. One
way to think about encapsulation is as a protective wrapper
that prevents code and data from being arbitrarily accessed
by other code defined outside the wrapper.
Real Time Example:
1.Ink is the important component in pen but it is hiding
by some other material
2.Medical Tablet
i.e one drug is stored in bottom layer and another drug is
stored in Upper layer these two layers are combined in
single Tablet.
Inheritance:The new classes, known as derived classes, take over (or
inherit) attribute and behavior of the pre-existing classes,
which are referred to as base classes (or Parent classes).
It is intended to help reuse existing code with little or no
modification.
Real Time Example:
1. Father and Son Relationship
Polymorphism:Single Form behaving differently in different Situations. A single
function or single operator has different characters in different places.
Real Time Example:
1.A girl plays a role of daughter at home and a manager at
office.
2. Person
Person in Home act is husband/son,
in Office acts Employer.
in Public Good Citizen.
<<<<<<<<<<<<<<<<------------------------->>>>>>>>>>>>>
OOPS Concepts with realtime examples
Abstraction helps to hide the non essential features from the user and makes the application user friendly.
Eg. Take your mobile phone. You are having buttons and know the purpose but no need to understand how it prints number on the screen when it is pressed.
2. Encapsulation
It bundles the code into a single unit which makes the code very easy to handle.
Eg.
Take computer keyboard. All the buttons have been enclosed.
3. Inheritance
It helps to inherit the superclass properties to subclasses.
Eg. Father - Son relationship.
4. Polymorphism
A entity which behaves differntly at different places.
Eg. A person behaves as a good husband in family.
He behaves as a good employee at company.
He also behaves as a good citizen in public.
No comments:
Post a Comment