Interface Example-2


 

Interface Example-2

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

The motive of this example is that to show that interface can extend another interface.
interface InterfaceA
{
  void abc();
  void xyz();
}

interface InterfaceB extends InterfaceA
{
  void show();
}

 class ClassX implements InterfaceB
{
  public void xyz()
  {
    System.out.println("xyz called");
  }
  public void show()
  {
    System.out.println("using interface InterfaceA and InterfaceB");
  }
  public  void abc()
  {
    System.out.println("abc called");
  }
}

class InterfaceExample2
{
  public static void main (String[] args
  {
    
    ClassX z1=new ClassX();
    z1.xyz();
    z1.abc();
    z1.show();
      
    }

Ads