Encapsulation

Encapsulation is the clear separation between the external interface of a class and its internal implementation; that is, the packaging together of properties and methods (or data and operations) for an object.

Encapsulation hides the implementation (internal structure) of an object from the surrounding system. Other objects can access only properties and methods that define the external characteristics of the object.

An object can hide some or all of its implementation from other objects, but can provide methods by which other objects can manipulate its internal state.

An object is like the proverbial engineering "black box". You can change the way a method is implemented without changing the object’s interface or its relationships with other objects.

You can hide implementation details to:

Properties are protected by default.