Interface Example-3


 

Interface Example-3

The motive of this example is to show that a class can implement more than one interface

The motive of this example is to show that a class can implement more than one interface
interface InterfaceX {
  public void methodx();
}

interface InterfaceY {
  public void methody();
}

interface InterfaceZ {
  public void methodz();
}

class ClassXY implements InterfaceX, InterfaceY, InterfaceZ {
  public void methodx() {
    System.out.println("method x of InterfaceX");
  }

  public void methody() {
    System.out.println("method x of InterfaceY");
  }

  public void methodz() {
    System.out.println("method x of InterfaceZ");
  }
}

class InterfaceEx3 {
  public static void main(String arg[]) {
    ClassXY y = new ClassXY();
    y.methodx();
    y.methody();
    y.methodz();
  }
}

/*
 * ------------------OUTPUT------------------------ method x of InterfaceX
 * method x of InterfaceY method x of InterfaceZ
 */

Ads