0 votes
in JAVA by
What is encapsulation in java

1 Answer

0 votes
by

The idea behind encapsulation is to hide the implementation details from users. If a data member is private it means it can only be accessed within the same class. No outside class can access private data member (variable) of other class.

However if we setup public getter and setter methods to update (for example void setName(String Name ))and read (for example String getName()) the private data fields then the outside class can access those private data fields via public methods.

Related questions

0 votes
asked May 2, 2021 in JAVA by sharadyadav1986
+1 vote
asked May 24, 2019 in JAVA by rajeshsharma
...