Interface Example-4


 

Interface Example-4

The motive of this example is to show an interface can extend another interface.

The motive of this example is to show an interface can extend another interface.
interface Interface1
{
  public void method1();
}

interface Interface2 extends Interface1
{
   public void method2();
}

class ClassA implements Interface2
{
   public void method1()
  {
    System.out.println("method1");
  }
    public void method2()
  {
    System.out.println("method2");
  }
}

public class InterfaceEx4 {
  public static void main(String args[])
  {
    ClassA a = new ClassA();
    a.method1();
    a.method2();
  }
}

/*-----------------------OUTPUT--------------------------
method1
method2
 */

Ads