Bird
0
0

What is the main reason to declare a method as static in Java?

easy📝 Conceptual Q2 of 15
Java - Static Keyword
What is the main reason to declare a method as static in Java?
ASo it can be called without creating an object
BSo it can access instance variables directly
CSo it can override instance methods
DSo it can only be called inside the class
Step-by-Step Solution
Solution:
  1. Step 1: Understand static method usage

    Static methods belong to the class and can be called without creating an object.
  2. Step 2: Instance method limitations

    Instance methods require an object to be called and can access instance variables.
  3. Final Answer:

    So it can be called without creating an object -> Option A
  4. Quick Check:

    Static method call without object = B [OK]
Quick Trick: Static methods can be called using class name directly [OK]
Common Mistakes:
  • Assuming static methods can access instance variables
  • Thinking static methods override instance methods
  • Believing static methods are private by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes