0 votes
in JAVA by
How is encapsulation achieved in Java?

2 Answers

0 votes
by

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.

0 votes
by

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.

Related questions

0 votes
asked May 2, 2021 in JAVA by sharadyadav1986
0 votes
asked Feb 8, 2021 in JAVA by SakshiSharma
...