Encapsulation is the mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. It helps in data hiding and security.