Can a normal Class implement multiple interfaces?

Joshua picture Joshua · Jan 21, 2014 · Viewed 154.4k times · Source

I know that multiple inheritances between Interfaces is possible, e.g.:

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:

public class A implements C,D {...} //Where A is a Class and C and D are interfaces

Answer

Christian picture Christian · Jan 21, 2014

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:

public class A implements C,D {...}