- The ability of an object to be a container for its member properties, including variables and methods.
- A fundamental principle of OOP, encapsulation plays a major role in languages such as C++ and Java.
- Hides variables from the rest of the program
- Use getter/setter methods that are public to access them
- Variables marked as private can only be seen/modified through the use of public accessor (getter) and mutator (setter) methods
- Helps you to control who accesses what
- Which function has access to a certain variable
- Makes a code flexible and easy to change
- Testing is more manageable (unit)
- An object's behavior is exposed through methods
- Hiding internal data from the outside world
- Accessing it only through publicly exposed methods