Encapsulation

In this lesson, you'll get familiar with one component of data hiding, encapsulation.

We'll cover the following

Definition

Encapsulation is a pillar of the object-oriented programming paradigm and is used to achieve data hiding.

Encapsulation in OOP refers to binding the data and the methods manipulating that data together in a single unit (class).

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

Get hands-on with 1200+ tech skills courses.