Multiple inheritance with class and interface

In this blog, we will see one sub class extends with super class and implements with interface. This is multiple inheritance structure in java programs.

Multiple inheritance structure

Super Class                            Interface

| [extends]                              | [implements ]



Sub Class


Inter1 in InterPack1 package

package InterPack1;

public interface Inter1   // Interfaces


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

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


SuperClass in clExample Package

package clExample;

public class SuperClass


                public void methodSuper()


                                String name[] = {“A”,”B”,”C”,”D”,”E”};

                                for(int i=0;i<name.length;i++)






Class D in classStore Package

package classStore;

import clExample.*;

import InterPack1.*;

// Note : must extends class 1st then implements interface

public class D extends SuperClass implements Inter1


                public void method1()




                public void methodD()


                                System.out.println(“Welcome in D Class”);



Class Example4 in mainPackage

package mainPackage;

import classStore.D;

public class Example4


                public static void main(String[] args)


                                // Create D Class object for all method access

                                D obj = new D();


                                obj.method1(); // interface method

                                obj.methodD();                // own class method

                                obj.methodSuper(); // super class method





Welcome in D Class






Video available on YouTube.



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

Earn Money Online

1176total visits,2visits today


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

Related articles

Comments are closed.