Home Tutorial Java Certification Interface Example-4

 
 

Share on Google+Share on Google+
Interface Example-4
Posted on: July 1, 2010 at 12:00 AM
Advertisement
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
 */
Advertisement

Related Tags for Interface Example-4:


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