What is Encapsulation in Java
Encapsulation is one of the principle of OOPs.
Encapsulation is a process of arranging information about data and behavior into a single component like as object in Java.
Keeping all members and methods are within bounds of class. In Java, all class are under encapsulated.
If we set all fields of class as private, so no other code outside of this class can not access private variables. To access these private variables, we have to declare public methods in class.
So these private members are not accessible by outside objects or classes.
A class can have authority to modify the values using setter and getter methods of class. By using getter methods, we can make read-only and wise versa for write-only.