Abstraction & Encapsulation in OOPS(Object Oriented Programming)

Опубликовано: 24 Июль 2026
на канале: Saurabh Singh
65
2

Today we are going to Learn About Abstraction and Enscapsulation, Two big pillars of OOPS.

Abstraction is "To represent the essential feature without representing the background details."

Abstraction lets you focus on what the object does instead of how it does it.

Wrapping up a data member and a method together into a single unit (in other words class) is called Encapsulation.

Encapsulation is a technique used to protect the information in an object from another object.

Lets Take example of generation of mobiles.

First came the mobile phones with only calling feature.

Second generation of mobiles we can send SMS, please note down we have not mentioned calling feature.

Then comes the thrid generation of mobiles with SMS and MP3, Again thing need to be noted down SMS and MP3 , we have not mentioned calling feature.

Fourth generation SMS +MP3+Video and what not, calling feature is obivious in all the mobiles , which makes its an abstract method.

We are hiding calling feature in all mobiles which is an abstract method of all.

Now Lets Take Exampleof encapsulation method.

Enscapsulation is a process of hiding the implementation from the user, only the functionality is exposed here. So you are aware only of what the application does, not how it does it.

Lets Take example using an ATM Analogy

You first Enter your card ino ATM, Enter Pin , Withdraw ammount , Simple Process to get money 24 hours.

So your PIN, would probably be retrieved in an encyrpted form, verified and only then you are given access. You do not have any control, over how the password is verified, and this keeps it safe from misuse.