Bird
0
0

What must a Java class do when it implements an interface?

easy📝 Conceptual Q1 of 15
Java - Interfaces
What must a Java class do when it implements an interface?
AExtend the interface as a superclass
BProvide implementations for all interface methods
CDeclare the interface methods as private
DCreate objects of the interface
Step-by-Step Solution
Solution:
  1. Step 1: Understand interface contract

    Interfaces define method signatures without bodies, so implementing classes must provide method bodies.
  2. Step 2: Implement all interface methods

    The class must implement all methods declared in the interface to fulfill the contract.
  3. Final Answer:

    Provide implementations for all interface methods -> Option B
  4. Quick Check:

    Implementing interface = Provide all methods [OK]
Quick Trick: Implement all interface methods to avoid errors [OK]
Common Mistakes:
  • Trying to extend an interface as a class
  • Not implementing all interface methods
  • Declaring interface methods private

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes