Wednesday, January 4, 2012

JAVA : OOP - Interface

Below example for Interface programming.


interface calc {
public int calc(int a, int b);
}
public class MyInterface implements calc{
public int calc(int a,int b )
{
return a + b; }
public static void main(String[] args)
{
MyInterface testInterface = new MyInterface();
int total;
total = testInterface.calc(1,7);
System.out.println("Total:" + total);
}
}


Interface only declare the method only. not include with the method body.

No comments:

Post a Comment