Junior — Middle
What is the maximum number of interfaces a class can implement in Java?
sobes.tech AI
Answer from AI
In Java, a class can implement an unlimited number of interfaces. There are no restrictions on the number of interfaces that can be implemented.
For example:
public interface InterfaceA {}
public interface InterfaceB {}
public interface InterfaceC {}
public class MyClass implements InterfaceA, InterfaceB, InterfaceC {
// Implementation of interface methods
}
This allows a class to inherit behavior from multiple sources, which promotes flexibility and extensibility of the code.