Interface Inheritance in Java


Write a Java program to demonstrate the concept of interface inheritance

  • Vehicle is an interface that declares a method start().
  • Car is an interface that extends the Vehicle interface and declares a method stop().
  • Sedan is a class that implements the Car interface. It provides implementations for both start() and stop() methods.
  • In the Main class, an instance of Sedan is created. The start() and stop() methods are called on the sedan object, resulting in printing "Sedan is Starting" and "Sedan is Stopping" to the console, respectively.

Source Code

interface Vehicle
{
	void start();
}
 
interface Car extends Vehicle
{
	void stop();
}
 
class Sedan implements Car
{
	@Override
	public void start()
	{
		System.out.println("Sedan is Starting");
	}
 
	@Override
	public void stop()
	{
		System.out.println("Sedan is Stopping");
	}
}
 
public class Main
{
	public static void main(String[] args)
	{
		Sedan sedan = new Sedan();
		sedan.start();
		sedan.stop();
	}
}

Output

Sedan is Starting
Sedan is Stopping

Example Programs