Home Tutorial Java Certification Interface Example-4

 
 

Interface Example-4
Posted on: July 1, 2010 at 12:00 AM
The motive of this example is to show an interface can extend another interface.
interface Interface1
{
  public void method1();
}

interface Interface2 extends Interface1
{
   public void method2();
}

class ClassA implements Interface2
{
   public void method1()
  {
    System.out.println("method1");
  }
    public void method2()
  {
    System.out.println("method2");
  }
}

public class InterfaceEx4 {
  public static void main(String args[])
  {
    ClassA a = new ClassA();
    a.method1();
    a.method2();
  }
}

/*-----------------------OUTPUT--------------------------
method1
method2
 */

Related Tags for Interface Example-4:


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.