Showing posts with label java progammings. Show all posts
Showing posts with label java progammings. Show all posts

Real life examples of polymorphisms, encapsulation and inheritance?

polymorphisms:-
polymorphisms is nothing but ability to take more than one forms(One Interface,Multiple Methods or One Name,Many Forms).

Encapsulation:-
-is nothing but wrapping the data and functions into single entity.

Inheritance:-
The Process of deriving new class from existing class.This is called Inheritance.
New Class-Child Class
Existing Class-Parent Class

Types:
*Single Inheritance
*Multiple
*Hybrid
*Multilevel
*Hierarchical
Polymorphism:

say a door..
a door to a temple, a door to a house, a door to a kitty house,
all are doors, but all look different

Encapsultion:

cars and owners...
all the functions of cars are encapsulated with the owners..
No one else can access it...


Inheritence:

Kingfisher jet
^
|
Airplane
^
|
Flying Things

polymorphism:
Poly = many
morphs = forms
existing in many forms.
It is achieved by OVERLOADING and OVERRIDING.

EXAMPLE: We behave diffrently in front of elders, and friends.
a single person is behaving diffrently at diffrent time.

ENCAPSULATION:
Wrapping up data and member functions in a single unit for easier and safer access.

INHERITANCE:
A new class(child) can be based on existing class(parent) deriving functionallity from parent class.


Polymorphisam: An Object is in different forms and in each form its exhibit the same functionality but the implementation is different.

Eg: A Person who knows more than two languages he can speak in a language which he knows. Here person is Object and speak is polymorphisam.

Inheritance: The process of eqiring the existing functionality of parent and with new added features and functionality of a child Object.

A secintific calculator is a extend form of Caluculator here Caluculator is parent and secintific calculator is Child object.

Encapsulation: Binding of data and behavior i.e functionality of an object in a secured and controlled manner.
POLYMORPHISM-
poly means "MANY" ,
morphism means "FORMS"..
MEANS many forms
or u can say that a object(person,place or thing) acts differently in different situations
example-
if a girl is married and mother of 2 children doing teaching job den
she is a women first ,, teacher in a school whn she is in school,,wife of someone at home,, mother of her children,, and obvious daughter of someone & may be girl friend of someone (just kidding) means a woman plays diffent roles at different times dats the polymorphism (many forms)
now overloading is achivd in c# by two ways a)method overloading also called compile time polymorphism
b)method overridind also known as run time polymorphism.
======================
inheritence= means to inherit(adopt) the feature/functionality of base class and also add their own functionality..
EXMPLE- a child inherit(adopt) some features of their parents & also add some features of their own
ENCAPSULATION-means hide/bind something ex- a capsule (which we consume whn v r ill)hide/bind some powder form in itself,, means that capsule encapsulate the powder contained it.
or the best example of encapsulation is a CLASS becoz a class hides class variables/functions from outside d class..

i hope u get wht u want.....
if not then u can msg and time 24/7