Interface extends with interface

In this blog, we will see one interface extends with another interface. Using of this structure, class needs to implements with only sub interface.

Interface extends another interface



|           [ extends ] [ Implements ]


|           [ Implements ] [ extends ]





Inter1 in InterPack1 package

package InterPack1;

public interface Inter1   // Interfaces


                public int x = 10;                // it’s final variable          

                public void method1();  // Indexing | Only Dec


Inter3 in InterPack2 package

package InterPack2;

import InterPack1.*;

public interface Inter3 extends Inter1


                public void method3();  // dec only | indexing


Class c in classStore Package

package classStore;

import InterPack2.*;

public class C implements Inter3


                public void method1()


                                System.out.println(“Inter 1”);


                public void method3()


                                System.out.println(“Inter 3”);



Example3 class in mainPackage package

package mainPackage;

import InterPack2.*;

import classStore.*;

public class Example3


                public static void main(String[] args)


                                // Just create Inter3 object

                                Inter3 obj = new C();

                                obj.method1(); // call to 1st Interface method

                                obj.method3(); // call to 3rd Interface method







Video available on YouTube.



If you have any query on blog example, you can directly comment us or subscribe our website

Earn Money Online

1517total visits,2visits today


Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Comments are closed.