Encapsulation

Get familiar with one of the components of data hiding, encapsulation.

We'll cover the following

Definition

Encapsulation is a fundamental programming technique used to achieve data hiding in OOP.

Encapsulation in OOP refers to binding data and the methods to manipulate that data together in a single unit, that is, class.

Depending upon this unit, objects are created. Encapsulation is usually done to hide the state and representation of an object from outside. A class can be thought of as a capsule having methods and properties inside it.

Get hands-on with 1200+ tech skills courses.