Home Tutorial Java Certification Interface Example-2

 
 

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

Related Tags for Interface Example-2:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.