Share on Google+Share on Google+

Interface Example-2

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

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.