Can i use 'public' access modifier for all the modules used? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Can i use 'public' access modifier for all the modules used?

And what is the use of the public access modifier anyway?

17th Dec 2016, 10:19 AM
Rohit thapliyal
Rohit thapliyal - avatar
3 Respuestas
+ 1
Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties' direct access to them. When public is defined means that every other class has access to it. Generally internal attributes are private and classes are public.
17th Dec 2016, 10:37 AM
Felipe Cruz
Felipe Cruz - avatar
+ 1
And can I use static keyword for all the modules? And what is the use of static keyword in front of modules.
17th Dec 2016, 4:20 PM
Rohit thapliyal
Rohit thapliyal - avatar
0
Static keyword creates fields and methods that belong to the class, rather than to an instance of the class. For exemple, static variables are called class variables, as it belong to the whole class.
17th Dec 2016, 4:29 PM
Felipe Cruz
Felipe Cruz - avatar