Multiple inheritance is Possible in Java?

Answer of above question is mention in below figure. Yes, Multiple inheritance possible in java using of interfaces.

Interface1                               Interface2

            |                                           |   [ 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


Inter2 in InterPack2 Package

package InterPack2;

public interface Inter2   // Interfaces


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


Class B in classStore Package

package classStore;

import InterPack1.*;

import InterPack2.*;

public class B implements Inter1 , Inter2                // Multiple inheritance


                public void method2()


                                System.out.println(“Welcome in Inter2”);


                public void method1()


                                System.out.println(“Welcome in Inter1”);



Class Example2 in mainPackage package

package mainPackage;

import classStore.*;

import InterPack1.*;

import InterPack2.*;

public class Example2


                public static void main(String[] args)


                                Inter1 i1 = new B();

                                Inter2 i2 = new B();

                                i1.method1();    // from inter1

                                i2.method2();    // from inter2





Welcome in Inter1

Welcome in Inter2


Video available on YouTube. : Multiple Inheritance 



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


Earn Money Online

1078total visits,1visits today


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

Related articles

Comments are closed.