Programming, Object Oriented, Java.
restricting access to public methods. Instance variables are kept private and accessor methods are made public to achieve this. For example, we are hiding the name and dob attributes of person class in the below code snippet. Encapsulation — private instance variable and public accessor methods.