Home Tutorial Java Certification Interface Example-1

 
 

Share on Google+Share on Google+
Interface Example-1
Posted on: July 1, 2010 at 12:00 AM
Advertisement
The motive of following code is that a concrete class can hold an interface and how to call that interface.
class ClassA
{
  void abc()
  {
    System.out.println("ClassA");
  }
  interface InterfaceA
  {
    void show();
  }
}

class ClassZ extends ClassA implements ClassA.InterfaceA
{
  public void abc()
  {
    System.out.println("acb() called");  
  }
  public void show()
  {
    System.out.println("show() method called ");
  }
}


class InterfaceExample1
{
  public static void main(String ar[])
  {
    ClassZ z1=new ClassZ();
    z1.abc();
    z1.show();
  }
}

/*
acb() called
show() method called 
*/
Advertisement

Related Tags for Interface Example-1:


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