Encapsulation is a technique for hiding the values or state of a structured data object within a class, preventing direct access by clients from exposing secret implementation details or violating the methods' state invariance.