Java - InterfacesWhat must a Java class do when it implements an interface?AExtend the interface as a superclassBProvide implementations for all interface methodsCDeclare the interface methods as privateDCreate objects of the interfaceCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand interface contractInterfaces define method signatures without bodies, so implementing classes must provide method bodies.Step 2: Implement all interface methodsThe class must implement all methods declared in the interface to fulfill the contract.Final Answer:Provide implementations for all interface methods -> Option BQuick 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 classNot implementing all interface methodsDeclaring interface methods private
Master "Interfaces" in Java9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Java Quizzes Abstraction - Abstract vs concrete classes - Quiz 5medium Constructors - Parameterized constructor - Quiz 11easy Constructors - Constructor overloading - Quiz 5medium Constructors - This keyword usage - Quiz 11easy Constructors - Constructor execution flow - Quiz 7medium Exception Handling - Why exception handling is required - Quiz 12easy Exception Handling - Finally block - Quiz 5medium Exception Handling - Checked vs unchecked exceptions - Quiz 1easy Exception Handling - Try–catch block - Quiz 14medium Polymorphism - Method overriding rules - Quiz 5medium