Introduction
We are going to see here some real life examples of Object Oriented Programming (OOPS).
The following are the principles of OOPS:
- Class
- Object
- Constructor (Note: This is not actual principal)
- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
- Destructor (Note: This is not actual principal)
Description
Before proceeding further let’s look into background.Before OOPS concept came into picture (market) there was "C Language" designed & developed by Dennis Ritchie in 1972 at AT & T Laboratory.
C language is a general purpose, block structured, case sensitive & procedure oriented language.
Program execution always goes from top to bottom.
Let’s see how a C program gets compiled & run.
CLR like the following figure:
Example
This example is divided into two parts; firstly, Procedure Oriented approach and secondly Object oriented approach.
There is one poor family in Maharashtra. They have their own business to pick up fish from sea & sell that in the local market. In that family there were members including husband, wife & children. Everyday they do the same thing for their business. After some years they did not earned a good amount of profit from their business because daily expenses were bigger than what they earned from the business.
So husband & wife decided to do some other business. So they visited on of their relatives and ask for some suggestions. They got a suggestion to make Ganesh statues to sell them. This was suggested because it is one of the best business since Ganesh Chaturthi is an important festival and celebrated across Indian homes.
They follow the procedural approach like C program approach:
- They take Shaadu (Fire Clay / dry mud powder), water, knot, color, brush, etc.
- First they take Shaadu in a vessel and start mixing water. Keep in mind the mixture can get very thick making your fingers ache as you try to take off the clay sticking on them.

- After this mixture is ready, give them a shape of Ganesh statue.

- Start off with creating a base structure of the idol / Ganesh statue:

- Leave the idol / statue to dry naturally for 2 days at least, after 2 days if statue is completely dry then start giving color to them.
For doing the above procedure they need extra time & days because firstly they have to give it a proper shape, statue should need to dry completely, after that give proper color to this statue. If sometimes statue gets cracked or shape didn't came out well, then they have do repeat the whole procedure from first to last. So it is very time consuming.
In this procedure suppose for completing 1 Ganesh statue it takes 5 days i.e approximately each month they completed 6 Ganesh statue (every year 72).
For first year they sold 72 statues. After this 72 statue reached in 72 homes, relatives & neighbours loved the statue. So for next year this family got an advance order of 2000 Ganesh statue which are in different shapes like 1 feet, 2 feet, 5 feet, 10 feet & 20 feet.
The family member again visited their relative to resolve these relevant questions i.e How can they complete 2000 Ganesh statues in one year? So they gave suggestion to use mold (meaning - a hollow container used to give shape to molten or hot liquid material when it cools and hardens) to give proper shapes to Ganesh statues.
Now the family used these different molds like 1 feet, 2 feet, 5 feet, 10 feet & 20 feet. Following this, they can complete 100 Ganesh statue per day.
Here they followed the procedure which is Object Oriented Programming Approach.
- Firstly, they took Shaadu in a vessel and started mixing water, after they took knot, mixed it in that pot & added this knot to mold.

This mold is like a predefined class.
Class
- Class is a blue print of newly created things.
- Class contains characteristics (class members) and behaviors (function applied on these characteristics).
- It is a blue print such as if we bought a land / space & would like to build a beautiful house on that land then we first draw a sketch.
- In our programming language before going to create any application first we decide which classes we are going to create.
- class Ganesh_Statue {
- // class members declerations
- public string shaadu;
- public string knot;
- public string water, pot;
- public string One_Tusk, Big_Head;
- public string chain, ring;
- public string mouse_color, Eye_Color, Skin_Color;
- public void Do_Painting() {}
- }
Object
- Objects are instances of class.
- Whenever they create first Ganesh statue from this mold, it creates first object & it will look like the following:

- Whenever they create multiple Ganesh statues (multiple objects) by using mold and added other parts like hand, legs etc, it looks like the following:
Abstraction
- Abstraction means hiding the implementation details.
- This family only knows which type of material they have used to create a statue.
- This family uses knot, shaadu, water, etc to make the statue and this information is hidden from the users (who can buy this Ganesh statues).
If we ask anybody that what we can understand from the above image, then he / she will say that these are all stones.
Constructor
- Constructor is a method that is called when instance of an object is created.
- They have the same name as a class.
- In our example default constructor is to be set with values such as eye color, skin color and mouse color.
- After calling the default constructor Ganesh statue will look like the following:

A. Parameterized Constructor- //constructor
- public Ganesh_Statue() {
- Console.WriteLine("**** Dafult Constructor in base class starts from here ****");
- Eye_Color = "Black";
- Skin_Color = "Redish_White";
- mouse_color = "Black";
- Console.WriteLine("Default values of Eye color: " + Eye_Color);
- Console.WriteLine("Default values of skin color: " + Skin_Color);
- Console.WriteLine("Default values of mouse colo: " + mouse_color);
- Console.WriteLine("____________________________________________________________________________");
- Console.WriteLine();
- }
- A constructor with at least one parameter is called parameterized constructor.
- In our example suppose a wealthy businessman came to this family & gave some parameter like he wants to add his own jewellery to statue like chain & ring.
- // parameterized constructor
- public Ganesh_Statue(string x, string y) {
- chain = x;
- ring = y;
- Console.WriteLine("____________________________________________________________________________");
- Console.WriteLine("**** Parameterized Constructor of base class starts from here ****");
- Console.WriteLine("chain color: " + x + " ring color: " + y);
- Console.WriteLine("____________________________________________________________________________");
- Console.WriteLine();
- }
Encapsulation
- Encapsulation means biding data & function together.
- For example, we visit the Doctor or Medical store and take medicine(capsule / tablet), then the plastic cover is used to bind with inner powder which helps us to recover.
Polymorphism
Now this family has to decide about some people who have domain specific knowledge like painting.





mathi mPosted Feb 19, 2022, 2:20 PM
Thank you , oops concept simply cleared
Mr. SabihPosted Sep 24, 2021, 9:22 AM
Explanation couldn't be more perfect than this one.
srujanasri PotharajulaPosted Aug 11, 2021, 7:21 AM
Excellent explanation
Sanjay KumarPosted Aug 2, 2021, 12:51 PM
Nice article & very usefull
Saurabh VasaniPosted Apr 16, 2018, 2:45 AM
Thanks and really appriciable....Keep it up bro....
Shubham JainPosted Jan 12, 2018, 6:43 PM
Perfect way to explain :)
chinnuPosted Nov 16, 2016, 7:03 AM
Nice one and thank you for your time.
Bhuvanesh MohankumarPosted May 10, 2016, 2:27 AM
Good one..
Sonu ChaudharyPosted Mar 16, 2016, 3:23 AM
great
Rupesh KahanePosted Feb 5, 2016, 2:05 PM
thanks to Akanksha Ladsawangikar & amit singh also
Amit Kumar SinghPosted Feb 3, 2016, 4:46 AM
Nice Article
Akanksha LadsawangikarPosted Jan 9, 2016, 3:50 AM
Nice example indeed! Would help to brush up OOPS concepts. :-)
Rupesh KahanePosted Dec 23, 2015, 8:18 PM
Thanks sreenivasa reddy ganta
sreenivasa reddy gantaPosted Dec 22, 2015, 8:58 PM
great job & great explanation ....thanks
Rupesh KahanePosted Nov 27, 2015, 5:40 AM
thanks Jaipal Reddy
Jaipal ReddyPosted Nov 27, 2015, 3:54 AM
Great work.
Rupesh KahanePosted Nov 17, 2015, 11:28 AM
Umamaheswara Rao Dasari thanks
Umamaheswara Rao DasariPosted Nov 17, 2015, 8:52 AM
wow
Rupesh KahanePosted Nov 4, 2015, 7:36 AM
Rupesh Sayankar thanks for your great words
Rupesh SayankarPosted Nov 4, 2015, 5:56 AM
Really Very Nice Article... permanant OOPs print in your brain...
Rupesh KahanePosted Oct 25, 2015, 1:38 PM
Thanks Santhakumar Munuswamy sir
Santhakumar MunuswamyPosted Oct 25, 2015, 11:56 AM
Good one
Rupesh KahanePosted Oct 19, 2015, 1:55 PM
Priyaranjan K S thanks a lot
Rupesh KahanePosted Oct 19, 2015, 1:55 PM
Gowtham K thanks
Priyaranjan K SPosted Oct 19, 2015, 12:42 PM
Good One
Gowtham KPosted Oct 19, 2015, 12:31 PM
Good job
Rupesh KahanePosted Oct 19, 2015, 9:43 AM
Thx mukesh, humayun, sanjay, rajan and sibeesh sir
Sibeesh VenuPosted Oct 19, 2015, 8:54 AM
Nice Share
Rajan AroraPosted Oct 19, 2015, 7:49 AM
Superb
Sanjay SabariyaPosted Oct 19, 2015, 7:05 AM
Excellent.
Humayun Kabir MamunPosted Oct 19, 2015, 6:50 AM
Nice...
Mukesh KumarPosted Oct 19, 2015, 5:13 AM
Good Job
Rupesh KahanePosted Oct 19, 2015, 4:51 AM
Thx kamlesh
Kamlesh BhorPosted Oct 19, 2015, 4:33 AM
Nice.. Thanks for sharing...
Rupesh KahanePosted Oct 19, 2015, 3:56 AM
Thanks sujeet sir
Sujeet SumanPosted Oct 19, 2015, 3:40 AM
Nice one......................
Rupesh KahanePosted Oct 19, 2015, 3:37 AM
Thx nilesh sir
Nilesh JadavPosted Oct 19, 2015, 3:03 AM
Good Share
Rupesh KahanePosted Oct 19, 2015, 2:13 AM
Thx harshad
Rupesh KahanePosted Oct 19, 2015, 2:13 AM
Thx vinodh
Vinodh NarayananPosted Oct 19, 2015, 2:04 AM
good one
Harshad PansuriyaPosted Oct 19, 2015, 1:57 AM
Nice one