Home Tutorial Java Certification Interface Example-2

 
 

Share on Google+Share on Google+
Interface Example-2
Posted on: July 1, 2010 at 12:00 AM
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();
      
    }
Advertisement

Related Tags for Interface Example-2:


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.

Posted on: July 1, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com