To understand what encapsulation means, it can be considered as “surrounding” an entity, to keep and protect whatever is inside the surrounding.
It has a similar concept in programming as well, here encapsulation has a wider meaning than combining the members together within a class; it has a function of access restriction to the inner workings of that class as well.
Access modifiers implements Encapsulation. An access modifier defines the scope and visibility of a class member.
Encapsulation is also termed as information hiding.
private double balance=0;
public void Deposit(double x)
balance += x;
public void Withdrawl(double x)
balance -= x;
public double FetchBalance()
We have a Control over the way data is accessed or modified.