+ 2
An object stores it's state in variables and exposes it's behavior through functions.
Encapsulation is the process in which a class encapsulates variables and functions.
Encapsulation is achieved by declaring variables as private (this process is known as data-hiding) and writing public methods to set and get values of that variables.
//example of encapsulation
public class Main
{
private String name;
public void SetName(String name){this.name=name;}
public String getName(){return name;}
}
Abstraction is the process of hiding the implementation details and only the functionality is provided. In short the user will know what the module does but not how.
Abstraction is achieved through abstract classes and interfaces