Encapsulation is a process where a class's variables or data are concealed from all other classes and are only accessible through member functions of the class in which they were declared.
The three types of encapsulation are member variable encapsulation, class encapsulation and function encapsulation.
A structured data object's values or state are buried inside a class using encapsulation to prevent direct client access that can reveal undocumented implementation details or compromise state invariance upheld by the methods.
When a lower-layer protocol gets data from a high-layer protocol, it encapsulates the data and inserts it into the data component of its frame.
We can ourselves define the encapsulation as public or private.