I know that multiple inheritances between Interfaces is possible, e.g.:
JavaScript
x
public interface C extends A,B { } //Where A, B and C are Interfaces
But is it possible to have a regular Class inherit from multiple Interfaces like this:
JavaScript
public class A implements C,D { } //Where A is a Class and C and D are interfaces
Advertisement
Answer
A Java class can only extend one parent class. Multiple inheritance (extends
) is not allowed. Interfaces are not classes, however, and a class can implement more than one interface.
The parent interfaces are declared in a comma-separated list, after the implements
keyword.
In conclusion, yes, it is possible to do:
JavaScript
public class A implements C,D { }