Image

Programs - Java - Core Java - Interface

Program:


interface I
{
void m1();
}
class Adapter implements I
{
public void m1()
{
 }
}
class HFC
{
public static void main(String[] args)
{
  HFC ob1=new HFC();
  I ob[]={new HFC().m1(),HFC.m2(),new HFC().m2(),new HFC().m3(),ob1.m2(),};
  for(int i=0;i<ob.length;i++)
   ob[i].m1();
 }
I m1()
{
  class NonStaticLocal implements I
  
{
   public void m1()
   
{
    System.out.println(" Method in Non Static Local");
   }
  }
  return new NonStaticLocal();
 }
static I m2()
{
  class StaticLocal implements I
  
{
   public void m1()
   
{
    System.out.println(" Method in Static Local");
   }
  }
  return new StaticLocal();
 }
Adapter m3()
{
  class StaticLocal extends Adapter
  
{
   public void m1()
   
{
    System.out.println("Method in Satic Local Common");
   }
  }
  return new StaticLocal();
 }
}