Encapsulation means bundling data with the mechanisms or methods that operate on the data.

It allows a consistent Interface and is common in Object Oriented Programming.

Below is an example in Java where the Employee’s salary is encapsulated:

  public class Employee {
    private BigDecimal salary = new BigDecimal(50000.00);

    public BigDecimal getSalary() {
        return this.salary;
    }

    public static void main() {
        Employee e = new Employee();
        BigDecimal sal = e.getSalary();
    }
}

See also: Encapsulation (computer programming) - Wikipedia