Java — Which three are valid method signatures in an interface?

Difficulty: Medium

Correct Answer: public float getVol(float x);, public void main(String [] args);, boolean setFlag(Boolean [] test);

Explanation:

Introduction / Context:This checks which method signatures are allowed inside interfaces.

Concept / Approach:

  • Interface methods are implicitly public and abstract (before Java 8).
  • private is not allowed for interface methods until Java 9 (the question assumes older standard, so it is invalid).
  • public static void main(String[] args) is not valid inside traditional interfaces (static methods in interfaces are only allowed in Java 8+).

Step-by-Step:

Option B: Valid abstract method.Option C: Valid abstract method (main like any method).Option E: Valid abstract method.

Final Answer:2, 3, and 5

More Questions from Declarations and Access Control

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion