What are encapsulated classes?
The process of hiding all the internal details of an object from the outside world is known as encapsulation. In Java or C++, encapsulation isenforced by having the definitions for attributes and methods inside a class definition.
The abstractions of data and methods to act on the data are encapsulated into a single unit. The states and behaviors of the abstraction are incorporated into an encapsulated whole, called a class. The actual internal implementation of the states and behaviors is hidden from the rest ofthe system.
For example consider a class Color that can be changed to green, white, red, etc. As long as the outside world continues to view Color as a Coloe object it does not matter how color is internally represented in the class. It could be RGB (Red, Green, Blue combination) or HSV (Hue, saturation and value).
The state and behavior of objects are controlled and altered by welldefined and restricted interfaces to the object. Thus encapsulation ensuresthat the internal details of an object are hidden from the outside world and that each object maintains its own unique identity and state, and that the state can only be changed by well-defined messages.
