1Z0-819 · Question #28
Which statement is true about the Fox class?
The correct answer is E. Fox class must provide an implementation for the inhabit method. When a concrete class implements an interface in Java, it must provide a body for every abstract method declared in that interface - including inhabit. Fox cannot skip this obligation simply by not calling the method (A is wrong), because the compiler enforces implementation at…
Question
Options
- AFox class does not have to override inhabit method, so long as it does not try to call it.
- BFox class must implement all three interfaces because they all have to provide compatible implementations.
- CFox class must implement either Forest or Town interfaces, but not both.
- DThe inhabit method implementation from the first interface that Fox implements will take precedence.
- EFox class must provide an implementation for the inhabit method.
How the community answered
(17 responses)- B6% (1)
- C12% (2)
- E82% (14)
Explanation
When a concrete class implements an interface in Java, it must provide a body for every abstract method declared in that interface - including inhabit. Fox cannot skip this obligation simply by not calling the method (A is wrong), because the compiler enforces implementation at class definition time, not at call time.
Why the distractors fail:
- A - The compiler doesn't care whether you call a method; if the interface declares it abstract, you must implement it or declare your class
abstract. - B - Fox doesn't need three separate implementations; one implementation with the matching signature satisfies all interfaces that share the same method signature simultaneously.
- C - Java imposes no "pick one" rule between interfaces; Fox can implement any number of interfaces, including both Forest and Town.
- D - Java has no "first interface wins" precedence rule. If there's a conflict between default methods, the class must override to resolve it - nothing is silently inherited by declaration order.
Memory tip: Think of each interface as a contract. Signing a contract (implementing an interface) legally obligates you to fulfill its terms (inhabit). If several contracts demand the same deliverable, one delivery satisfies all - but zero deliveries violates them all.
Topics
Community Discussion
No community discussion yet for this question.