+ 4
what is the need to keep the class private?
3 Answers
+ 1
The private access modifier is accessible only within class.
Simple example of private access modifier
let'say we have created two classes A and Simple. A class contains private data member and private method. We are accessing these private members from outside the class, so there is compile time error.
Note : We don't keep our main outer class as private ..generally class members are kept private to achieve encapsulation.
0
to protect from other method and class....
and we always make inner class as private not outer class...
0
only reason is to provide security to the class because any programmer would not like that his sensitive data to be accessed by unknown user