+ 2

Why data members in class is to be private?

11th Mar 2019, 4:36 AM
Manav Malhotra
Manav Malhotra - avatar
3 Réponses
+ 3
If you don't want to give access to another class to change your data member , it is to be declared as private. For example if a developer has made a new app and it has some data member , he built the app and he don't want client to read or change its source code, so at that time , creating a private data member is useful.!!hope you understand!
11th Mar 2019, 10:41 AM
shalini jha
shalini jha - avatar
11th Mar 2019, 6:44 AM
Sebastian Keßler
Sebastian Keßler - avatar
+ 1
Check out the comments on the lesson. https://www.sololearn.com/learn/Java/2162/?ref=app
11th Mar 2019, 8:07 AM
Lambda_Driver
Lambda_Driver - avatar