SEARCH
🇬🇧
MEM
O
RY
.COM
4.37.48
Guest
Log In
Â
Homepage
0
0
0
0
0
Create Course
Courses
Last Played
Dashboard
Notifications
Classrooms
Folders
Exams
Custom Exams
Help
Leaderboard
Shop
Awards
Forum
Friends
Subjects
Dark mode
User ID: 999999
Version: 4.37.48
www.memory.com
You are in browse mode. You must login to use
MEM
O
RY
  Log in to start
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