Java Program to Implement the Interface With Multi-Level Inheritance

You are currently viewing Java Program to Implement the Interface With Multi-Level Inheritance

Java program to implement the interface with multi-level inheritance

// Java program to implement the interface 
// with multi-level inheritance

interface Inf {
  void sayHello();
}

class Sample1 implements Inf {
  public void sayHello() {
    System.out.println("Hello World");
  }
}

class Sample2 extends Sample1 {
  public void sayHello1() {
    System.out.println("Hello World1");
  }
}

class Sample3 extends Sample2 {
  public void sayHello2() {
    System.out.println("Hello World2");
  }
}

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

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

Output

Hello World
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