Interface Example-3

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

 
 

Share on Google+Share on Google+

Interface Example-3

Ads

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
 */

Advertisements

Ads

Posted on: July 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles