Single Choice
Easy
QWhat is the purpose of "static" keyword in JAVA?
ID: #22220
static Keyword in Java
117 views
Question Info
#22220Q ID
EasyDifficulty
static Keyword in JavaTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
It allows the method to be called without creating an instance of the class.
Explanation:
In Java, the static keyword is used for:
-
Static Methods and Variables:
-
Methods: A static method belongs to the class rather than instances of the class. This means you can call the method directly on the class itself without needing to create an instance.
-
class Example { static void staticMethod() { System.out.println("Static method"); } } // Calling the static method without creating an instance Example.staticMethod();
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.