Introduction to Object Orientated Programming (OOP)

What is OOP?

Object Orientated Programming attempts to demystify and organize programming in a structured manner so that other programmers can work on it as well. It essentially works on objects rather than “actions” and data rather than logic. The language was formed by analyzing the very nature of the real world.

The following principles are the four pillars of the Real World. They give breath to the Real World and help it evolve and progress with time.

  • Abstraction: Shows relevant information

A good example of this principle is a remote control. A remote control only shows the user information that he or she is interested in. Buttons to change the volume and channel are accessible to the user as these are the ones that the user is most interested.

  • Encapsulation: Hides information that is unnecessary for user

Continuing the remote control analogy, users aren’t interested in the workings and operation of the device and so this is deliberately hidden. So, producers purposefully hide the colorful wires and boards within a compact case.

  • Polyamorphism: One object can take on many forms

A smartphone is the epitome of polymorphism. This one device can be put to different uses: it can calculate, call, research, text, click pictures etc. Thus, any device or component that has multiple functions is categorized in the polyamorphism group.

  • Inheritance: Takes information from the previous models and progresses

Inheritance is a critical component of all devices. This property makes devices reusable and saves time in the development of new products. A good example is the iPhone X. iPhone X was the daughter device of iPhone 7, as it has similar features except those features are more enhanced. iPhone 7 most likely inherited a few of its properties (ie operations and structure) from iPhone 6. We can go on and on, but you get the gist!

The OOP language attempted to combine all these features in one language so that the language would enhance and develop on its own with time. The language follows a regimented structure explained below:

import java.util.*; #similar to #include<iostream.h> in C++
public class FirstProgram #name of the folder
          private int num1, num2, sum; #this is what the users can't see
          Scanner scr = new Scanner(; #asking the software to take information from the keyboard

          public void accept()
                  System.out.print("\n\t Enter first number: "); #similar to cout<<"\n\t Enter first number: "; in C++
                  num1=scr.nextInt(); #similar to cin>>num1; in C++

                  System.out.print("\n\t Enter first number: ");
          public void calculate()
          public void display()
                  System.out.print("\n\t Sum of the nos: " + sum); #similar to cout<<"Sum of the numbers}<<sum;
          public static void main(String[] a)
                  FirstProgram obj=new FirstProgram();

This code is much more useful as it is more systematic, robust, and flexible. I can tweak a few things and write the Palindrome code or Fibonacci sequence, while with C++, I would have to write it from scratch. This is why OOP is favored!


One thought on “Introduction to Object Orientated Programming (OOP)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s