The encapsulation is mainly achieved by creating classes, the classes expose public methods and properties. The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes. In that sense, encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system.
The idea of encapsulation is to hide how a class does it but to allow requesting what to do.
The following picture explain the concept of Encapsulation.
