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

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.

Ads

Advertisement