+ 2
what is the difference between public and private class?
6 Answers
+ 4
In public classes all other classes in the main() can access data defined in it. Whereas private is used to restrict access only to a specific initiallised Data. For eg when making a game it is more secured to define the lives counter as private than public since a leakage or bug can result in midifiction of the lives. Get it?
+ 3
Public means it can be used in another class also but private means it's belongs to that particular class only hope u understood.
+ 3
Private is secured and thus used when we have to restrict the access of class.
But if u want keep it for open access then public is used.
+ 2
you can not access a private class from other classes whereas you have the access to a public class from everywhere.
+ 1
thanks
+ 1
you're welcome.đž