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


Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C