Implement the concept of interface using Java



Implement the
concept of interface, where interface contains two abstract method





Program:





interface A


 {


 final static
int i=10;


 void cal( );


 void Display(
); 


 }


class B implements A


{





  public void
Display()


    {


    
System.out.println( +i);


    }


 public void
cal( )


     {


        int
j=i+10;


       
System.out.println( "CAL "+j);


     }


}





class Sk21


 {


  public
static void main(String args[])


   {


    B obj=new
B();


   
obj.Display();


    obj.cal();


    }


 }





Compile:


D:\>javac
Sk21.java





Run:


D:\>java Sk21





Output:


10




CAL 20


0 Comments