How is encapsulation achieved in Java?
Encapsulation is achieved by wrapping up data and code into simple wrappers called classes. Objects instantiate the class to get a copy of the class data.
🔗Reference: stackoverflow.com
🔗Source: Java Interview Questions and Answers
We can achieve encapsulation by two simple ways:
• Stating the variables of a class as a private.
• Offering getter methods and public setter for changing and viewing variables values.