Bird
0
0

What is the correct way to call a static method calculate() defined inside an interface MathOps?

easy📝 Conceptual Q11 of 15
Java - Interfaces
What is the correct way to call a static method calculate() defined inside an interface MathOps?
AMathOps.calculate()
Bnew MathOps().calculate()
Ccalculate()
DMathOps obj = new MathOps(); obj.calculate()
Step-by-Step Solution
Solution:
  1. Step 1: Understand static method call in interfaces

    Static methods in interfaces are called using the interface name, not instances.
  2. Step 2: Analyze the options

    Only MathOps.calculate() correctly calls the static method. Creating instances or calling directly is invalid.
  3. Final Answer:

    MathOps.calculate() -> Option A
  4. Quick Check:

    Static method call = InterfaceName.method() [OK]
Quick Trick: Call static interface methods with InterfaceName.method() [OK]
Common Mistakes:
  • Trying to call static method on an instance
  • Calling static method without interface name
  • Trying to instantiate an interface

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes