Interface Inheritance Chain Example

This program demonstrates chained interface inheritance.

Problem Statement

Write a Java program where AdvancedDevice extends Device and SmartDevice extends AdvancedDevice.

Source Code

1 interface Device { void start(); }
2 interface AdvancedDevice extends Device { void stop(); }
3 interface SmartDevice extends AdvancedDevice { void restart(); }
4 class Mobile implements SmartDevice {
5 public void start(){ System.out.println("Eduinq Mobile Started"); }
6 public void stop(){ System.out.println("Eduinq Mobile Stopped"); }
7 public void restart(){ System.out.println("Eduinq Mobile Restarted"); }
8 }
9 public class InterfaceInheritanceChain {
10 public static void main(String[] args) {
11 System.out.println("Eduinq Interface Inheritance Chain");
12 SmartDevice sd=new Mobile();
13 sd.start(); sd.stop(); sd.restart();
14 }
15 }

Program Output

					Eduinq Interface Inheritance Chain
Eduinq Mobile Started
Eduinq Mobile Stopped
Eduinq Mobile Restarted
				

Explanation

Interfaces can extend other interfaces, forming inheritance chains. - SmartDevice inherits methods from AdvancedDevice and Device, creating a layered contract. - Mobile implements all methods, showing how one class can fulfill multiple levels of responsibility. - This design is powerful in enterprise systems where contracts evolve hierarchically, ensuring backward compatibility and extensibility. Conclusion: Shows interface inheritance chain example.

Quick Links to Explore