Share on Google+Share on Google+

Interface Example-3

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();

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



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

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.