4 Pillars for Object Oriented Programming.

The four pillars for OOP are Abstraction, Encapsulation, Inheritance, Polymorphism.

  1. Abstraction : Abstraction is the process of showing only essential/necessary features of an entity/object to the outside world and hide the other irrelevant information. For example to open your TV we only have a power button, It is not required to understand how infra-red waves are getting generated in TV remote control.
  2. Encapsulation : Encapsulation means wrapping up data and member function (Method) together into a single unit i.e. class. Encapsulation automatically achieve the concept of data hiding providing security to data by making the variable as private and expose the property to access the private data which would be public.
  3. Inheritance : The ability of creating a new class from an existing class. Inheritance is when an object acquires the property of another object. Inheritance allows a class (subclass) to acquire the properties and behavior of another class (super-class). It helps to reuse, customize and enhance the existing code. So it helps to write a code accurately and reduce the development time.
  4. Polymorphism: Polymorphism is derived from 2 Greek words: poly and morphs. The word "poly" means many and "morphs" means forms. So polymorphism means "many forms". A subclass can define its own unique behavior and still share the same functionalities or behavior of its parent/base class. A subclass can have their own behavior and share some of its behavior from its parent class not the other way around. A parent class cannot have the behavior of its subclass.

Correct me if anything is wrong.

Sources: books.

Max Qin

Passionate about data engineering.

9mo

I think the TV example in Abstraction is more like encapsulation. Abstraction means showing main features while encapsulation means hiding information.

Like
Reply
Etim Essang

Lead Software Engineer | Microservices, .NET & Flutter Expert | Automation & Project Leadership

1y

easy to understand

Like
Reply
Abdul Wahab Amir

MERN Stack Developer at Omnivex

3y
Like
Reply
Mubeen Ali

Senior Java Consultant | AWS Certified Solutions Architect | Expert in Java, Spring Boot, Python, Gen AI, and Microservices

3y

Very informative and to the point

Like
Reply
Austin S.

Software Engineer @ PAX Technology | Product Manager | EV Payment - E-Mobility | University of Florida Alumni

3y

Very useful!

Like
Reply

To view or add a comment, sign in

More articles by Pushkar Kumar

  • Java Productivity with Lombok: A Comprehensive Guide

    Java Productivity with Lombok: A Comprehensive Guide

    Java, as one of the most widely used programming languages, offers robust features for building enterprise-grade…

    5 Comments
  • Engineering Blogs

    Engineering Blogs

    It is always great to see great software companies out there with an open culture who like to share their experiences…

    11 Comments
  • How to check whether an integer is an odd number or not ?

    How to check whether an integer is an odd number or not ?

    Solution 1: public static boolean isOdd(int i) { return i % 2 == 1; } It seems to be correct but only for positive…

    5 Comments
  • Creating Deadlock in Java in a single statement

    Creating Deadlock in Java in a single statement

    Today I learnt, how to create a deadlock in java by using a single statement. /**  *  * @author Pushkar Kumar…

    9 Comments

Insights from the community

Others also viewed

Explore topics