Interface Extending Another Interface

This program demonstrates interface inheritance.

Problem Statement

Write a Java program where AdvancedPlayable extends Playable interface.

Source Code

1 interface Playable {
2 void play();
3 }
4 interface AdvancedPlayable extends Playable {
5 void pause();
6 }
7 class MusicPlayer implements AdvancedPlayable {
8 public void play(){ System.out.println("Music playing"); }
9 public void pause(){ System.out.println("Music paused"); }
10 }
11 public class InterfaceInheritance {
12 public static void main(String[] args) {
13 System.out.println("Eduinq Interface Inheritance");
14 AdvancedPlayable mp=new MusicPlayer();
15 mp.play(); mp.pause();
16 }
17 }

Program Output

Eduinq Interface Inheritance
Music playing
Music paused

Explanation

Interfaces can extend other interfaces. - AdvancedPlayable inherits play() from Playable and adds pause(). - MusicPlayer implements both methods, showing interface inheritance. Conclusion: Shows how interfaces can extend other interfaces.

Quick Links to Explore