Buscar
🇪🇸
MEM
O
RY
.COM
4.37.48
Invitado
Iniciar sesión
Página de inicio
0
0
0
0
0
Crear curso
Cursos
Último juego
Panel
Notificaciones
Clases
Carpetas
Exámenes
Exámenes personalizados
Ayuda
Marcador
Tienda
Premios
Amigos
Asignaturas
Modo oscuro
Identificador de usuario: 999999
Versión: 4.37.48
www.memory.es
Estás en modo de exploración. debe iniciar sesión para usar
MEM
O
RY
Inicia sesión para empezar
Index
»
Java Interview
»
Chapter 1
»
Modifiers
level: Modifiers
Questions and Answers List
level questions: Modifiers
Question
Answer
it's in a fixed position in memory and its impossible for it to be instanced like with non-static fields, class or methods. the static variable can be used to refer to the common property of all objects (i.e. not unique for each object). Its good to use static to make your program more memory efficent.
Static
When there is no access modifier specified on a class. Are visible inside the same package only. Default access is also called package access. Default variables and methods from SuperClass are available only to Subclasses in same package.
Default Class Modifier
Typically used in variables and methods. They can only be access in the class they are declared. Private variables and methods from SuperClass are Not available in Subclass.
Private Access Modifier
Protected variables and methods can be accessed in the same package Classes. Protected Variables and Methods from SuperClass are available to SubClass in any package.
Protected Access Modifier
Public variables and methods can be accessed from every other Java Classes. Public variables and methods from SuperClass are all available directly in the SubClass.
Public Access Modifier
Final Class cannot be extended. Example of a Final class in java is String and Integer (or other wrapper classes). This is to make the class immutable. Final is used rarely as it prevents reusing the class.
Final Modifier on a Class
Final Methods cannot be overridden. Any subclass extending the class cannot override the final method. It is the final definition.
Final Modifier on a Method
Once Initialized, the value of a final variable cannot be changed.
Final Modifier on a Variable
Final arguments value cannot be modified.
Final Modifier on a Argument