Register Now

Login

Lost Password

Enter your email to reset your password.

BY Author

Object Oriented Programming

These days Object Oriented Programming has become the most preferred programming approach by software industries.
Previously world used to prefer Procedure Oriented Programming languages.
C language is the most popular Procedure Oriented Programming language.
But as C++ started using Object Oriented Programming approach, software industry started loving it because it seems to be very easy and deals effectively with the complexity of real-world problems.
Therefore we have also tried to explain Object Oriented Programming concepts by giving real-world examples.

Object

Object is an actual physical existence of a Class. It is a real entity whose structure, identity and behavior are decided by a Class.

Class

Class is just known as a template or a blueprint for an Object. It is used to decide structure, identity and behavior of an Object.
It can also be considered as a mould for an object.

Object Oriented Programming OOP's Class & Object

Pillars of Object Oriented Programming (OOP)

Object Oriented Programming (OOP) is based on following main pillars,

1) Encapsulation
2) Abstraction
3) Inheritance
4) Polymorphism

1) Encapsulation

Object Oriented Programming OOP's Encapsulation

Encapsulation means binding different things together.
Similarly, in Object Oriented Programming, encapsulation brings all fields and methods (functions) together and binds into single unit named Class which provides security as well.
It’s like a capsule which encapsulates its different ingredients together within a cover.
Similarly, Class brings all methods and fields (Class members) together and provides security so that outside world cannot access its member without authorization.

2) Abstraction

Object Oriented Programming OOP's Abstraction

Abstraction means showing only essential aspects without including its details and ignoring the rest.
For example, a Car includes many engine parts, but they are hidden from us with the help of a car body because it is not necessary for us to drive a car. Only essential parts of a car like steering, brake, clutch & accelerator pedal, gear handle, etc. are kept open that are important for driving, without showing their details.
Similarly, abstraction enables Class to show essential aspects without including their details.
Abstraction is one of the important Pillar of OOP.

3) Inheritance

Object Oriented Programming OOP's Inheritance

Inheritance is the process by which one class inherits/acquires the properties of another class.
It is similar to inheritance in living creatures.

Example
In human beings, one human acquires the properties of another human through inheritance. That is, the child acquires some properties of its parents through inheritance as well as it contains its own properties.
                                                                                   OR
Son/Daughter gets the wealth from its parents, grandparents, and so on. The wealth is transferred from generation to generation. This is also one of the important examples of inheritance.
Similarly, in Object Oriented Programming, properties from one Class to another Class are transferred as long as inheritance is continued.

4) Polymorphism

Object Oriented Programming OOP's Polymorphism

Polymorphism is a mixture of two words poly and morphs taken from the Greek language.
Poly means many, morph means form.
In OOP the ability of an object to respond to the same process in different ways is called polymorphism.
Let’s look at a real-life example for better understanding.
A boy represents himself as a student in the classroom. The same boy represents himself as a Sportsman in ground and dancer at the dancing club.

 

Leave a reply