Abstraction is a quality that we simply don’t care about unnecessary internal mechanisms (implementations) and can deal with the system / object, considering the essence.
For example: When using brakes on a car, you don't care if it has an air brake or a hydraulic brake. Abstraction occurs in the form of pressing the pedal.
Encapsulation is what makes the above (abstraction) possible by packing (encapsulating) implementation details in a container (hiding the mechanisms of disturbance and tiny components from your vision or physical contact, in the above case).
So encapsulation actually provides an abstraction!
If you look around you can see it everywhere around you in the real world. In addition, he is present in programming. If someone provides you with a class for sorting integers, you don’t have to worry about the sorting algorithm (bubble sort / Quick sort) that it uses. Abstraction allows you to go through a list of integers to a method; i.e.
class Sorter { public List<Integer> Sort(List<Integer>)
See the animation below to see how neat abstraction is provided by encapsulating internal parts inside!
image courtesy: this blog

Winw
source share