Java MCQ: What does the ‘implements’ keyword do in Java?
Answer:
Explanation:
The implements
keyword in Java is used to indicate that a class is implementing an interface. An interface in Java is a reference type that can contain only abstract methods (until Java 8, which introduced default and static methods in interfaces). A class that implements an interface must provide concrete implementations for all the abstract methods declared in the interface.
When a class implements an interface, it is essentially agreeing to perform the behaviors defined by the interface’s methods. This allows for a form of multiple inheritance, where a class can implement multiple interfaces.
Understanding the implements
keyword is crucial for working with interfaces in Java, which are a powerful tool for designing flexible and modular code.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html