Encapsulation
From JholJhapata
Encapsulation is the process of wrapping the data and code under a single unit. It is the mechanism that binds together code and the data it manipulates. In a different way, encapsulation is a protective shield that prevents the data from being accessed by the code outside this shield.
Technically in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding.
Contents
Why do we need Encapsulation
Implementation of Encapsulation
Encapsulation is implemented by using access specifiers, which defines the scope and visibility of a class member:
- Public
- Private
- Protected
- Internal
- Protected internal