Interface Example-4

The motive of this example is to show an interface can extend another interface.

 
 

Share on Google+Share on Google+

Interface Example-4

Ads

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
 */

Advertisements

Ads

Posted on: July 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles