Interface extend Interface Java

Interface extend Interface Java


We know basically Java does not support multiple inheritance. But supports partially through interfaces. Interfaces were introduced just to support multiple inheritance. This tutorial explains inheritance styles with interfaces, inheritance between interfaces and Interface extend Interface.

One principle in inheritance is after extends there must come only one either concrete class or abstract class. But after implements should come only interfaces of any number.

1st style of Interface extend Interface

Following example illustrates inheritance of interfaces.

Interface extend Interface JavaOutput Screenshot on Interface extend Interface Java

class Demo implements two interfaces Test and Hello and overrides all the abstract methods of both interfaces. This everyone does and knows. See the second style.

2nd style of Interface extend Interface

Interface extend Interface JavaOutput Screenshot on Interface extend Interface Java

You get the same output of earlier but style of interfaces implementation is different.

Here class Demo implements Hello interface and inturn Hello interface extends Test interface. That is, between two interfaces use extends keyword; using implements raises compilation error.

To know more on Interface extend Interface, read Play with Implements and Extends Implements.

Practical application of Interface extend Interface comes in RMI (Remote Method Invocation) and EJB (Enterprise Java Beans).

Leave a Reply

Your email address will not be published. Required fields are marked *