Java MCQ: Which of the following statements about interfaces in Java is true?
Answer:
Explanation:
In Java, an interface can extend multiple other interfaces, allowing it to inherit the abstract methods from all the interfaces it extends. This is how Java supports multiple inheritance of type, even though it does not allow multiple inheritance of implementation (i.e., a class cannot inherit from more than one class).
Interfaces in Java cannot have instance variables or constructors. They are purely abstract types used to define a contract that classes must adhere to. All fields in an interface are implicitly public, static, and final, and methods are abstract by default (though they can also be default or static methods).
Understanding the nature of interfaces is crucial for designing flexible and reusable code in Java, especially in large systems where multiple classes need to share common behavior.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html