Java Program to Implement Multiple-Inheritance Using the Interface

You are currently viewing Java Program to Implement Multiple-Inheritance Using the Interface

Java program to implement multiple-inheritance using the interface

// Java program to implement multiple-inheritance 
// using the interface

interface Inf1 {
  void sayHello1();
}

interface Inf2 {
  void sayHello2();
}

class Sample implements Inf1, Inf2 {
  public void sayHello1() {
    System.out.println("Hello World1");
  }

  public void sayHello2() {
    System.out.println("Hello World2");
  }
}

public class Main {
  public static void main(String[] args) {
    Sample S = new Sample();

    S.sayHello1();
    S.sayHello2();
  }
}

Output

Hello World1
Hello World2

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply