Share on Google+Share on Google+

Interface Example-1

Advertisement
The motive of following code is that a concrete class can hold an interface and how to call that interface.
class ClassA
{
  void abc()
  {
    System.out.println("ClassA");
  }
  interface InterfaceA
  {
    void show();
  }
}

class ClassZ extends ClassA implements ClassA.InterfaceA
{
  public void abc()
  {
    System.out.println("acb() called");  
  }
  public void show()
  {
    System.out.println("show() method called ");
  }
}


class InterfaceExample1
{
  public static void main(String ar[])
  {
    ClassZ z1=new ClassZ();
    z1.abc();
    z1.show();
  }
}

/*
acb() called
show() method called 
*/

Advertisements

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.