Bird
0
0

Which statement best describes the behavior of fields declared in a Java interface?

hard📝 Conceptual Q10 of 15
Java - Interfaces
Which statement best describes the behavior of fields declared in a Java interface?
AInterfaces can have instance fields like classes.
BFields in interfaces are implicitly public, static, and final.
CFields in interfaces can be private and mutable.
DFields in interfaces are package-private by default.
Step-by-Step Solution
Solution:
  1. Step 1: Recall interface field rules

    Fields declared in interfaces are always public, static, and final by default.
  2. Step 2: Eliminate incorrect options

    Interfaces cannot have private or instance fields; fields are constants accessible everywhere.
  3. Final Answer:

    Fields in interfaces are implicitly public, static, and final. -> Option B
  4. Quick Check:

    Interface fields = public static final constants = C [OK]
Quick Trick: Interface fields are always public static final constants [OK]
Common Mistakes:
  • Thinking interfaces can have mutable instance fields
  • Assuming private fields are allowed
  • Confusing default access modifiers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes