Multiple inheritance in Java using interface

Posted on Aug. 13, 2019
Interface
multiple inheritance
java
1247

Multiple inheritance in Java using interface:

If a class implements multiple interfaces, or an interface extends multiple interfaces, it is known as multiple inheritance.

Example for Multiple Inheritance using Interface:

//Print.java

interface Prints
{  
   void print();  
}  

//Show.java

interface Shows
{  
   void show();  
}  

//Main.java

class Main implements Prints,Shows
{  
   public void print()
   {
       System.out.println("Hello");
   }  
   public void show()
   {
       System.out.println("Welcome");
    }  
   public static void main(String args[])
   {  
      Main obj = new Main();  
      obj.print();  
      obj.show();  
    }  
}  

 




0 comments

Please log in to leave a comment.