A class binds together data and its associated functions under one unit thereby enforcing encapsulation as encapsulation means wrapping up data and associated functions together into a single unit. While implementing encapsulation, following things are taken care of:
(i) Anything that an object does not know or cannot do is excluded from the objects.
(ii) Encapsulation is used to hide unimportant implementation details from other objects.
(iii) The data and associated functions are wrapped up in one unit called class. Through encapsulation, an interface is made available to world through which users can use the class.