+4

What is the importance of using the private access specifier in a program

When is it necessary for me to use it.

1/25/2020 10:13:29 AM

Joshua Evuetapha

7 Answers

New Answer

+4

Read the two answers by MeanMachine in the question below: https://www.sololearn.com/Discuss/1799032/

+7

This is for encapsulation and abstraction Private modifiers dont get inherit and cant be modified from outside of class and cant be modified on created instance

+4

To hide your data members from accessing outside of the class

+4

This is one of the key features of object oriented programming when you want to have information hiding and encapsulation, especially when you only want limited parts of the program to modify certain data.

+3

https://www.sololearn.com/discuss/1746189/?ref=app https://www.sololearn.com/discuss/826596/?ref=app https://www.sololearn.com/discuss/1799032/?ref=app

+3

Abstraction

+2

If you dont want it to be changed from other classes, with private only this class can access it. Its generally a good style to use private attributes and get and set methoded to modify this attributr instead of public attributes, cause it you change the attribute name you would have to change it everywhere it is used.