Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects” which may contain data, in the form of fields, often known as attributes, and code in the the form of procedures, often known as methods.

Four Pillars of OOP

There are said to be four pillars of OOP.  They are:

  • Abstraction
  • Encapsulation
  • Polymorphism
  • Inheritance


Abstraction is the process of hiding away the details, in order to focus on what’s important.  Showing only the essential details.


Encapsulation is hiding unnecessary data in a capsule or unit.  It is certainly about information hiding and organization.  


Polymorphism is the ability for an object to change its behaviour according to how it is being used.  There are two types:

  1. Dynamic polymorphism (run time).  This is done through function overloading
  2. Static polymorphism (compile time).


Inheritance is a way to reuse code.
The class that is inherited from is called the base class.
The class that inherits from the base class is called a derived class.
A derived class can use all the functions which are defined in the base class, making code reusable