Java - InterfacesWhich of the following statements about Java interfaces is true?AInterfaces can have instance variables.BInterfaces cannot extend other interfaces.CInterfaces can be instantiated directly using the new keyword.DInterfaces can contain method implementations using default methods.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand interface capabilitiesJava interfaces can have default methods with implementations since Java 8.Step 2: Evaluate each optionInterfaces cannot have instance variables (only constants), cannot be instantiated directly, and can extend other interfaces.Final Answer:Interfaces can contain method implementations using default methods. -> Option DQuick Check:Interface default methods = B [OK]Quick Trick: Interfaces can have default methods with code since Java 8 [OK]Common Mistakes:Thinking interfaces can have instance variablesTrying to instantiate interfaces directlyBelieving interfaces cannot extend other interfaces
Master "Interfaces" in Java9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Java Quizzes Abstraction - Abstract vs concrete classes - Quiz 15hard Classes and Objects - Object lifecycle - Quiz 2easy Classes and Objects - Object interaction - Quiz 7medium Constructors - Why constructors are needed - Quiz 9hard Custom Exceptions - Throwing custom exceptions - Quiz 12easy Custom Exceptions - Creating custom exception class - Quiz 1easy Exception Handling - Try–catch block - Quiz 10hard Inheritance - Constructor chaining - Quiz 6medium Interfaces - Static methods in interfaces - Quiz 9hard Object-Oriented Programming Concepts - OOP principles overview - Quiz 10hard