Sunday, February 8, 2015

Interface Sample Code

package com;

public interface TestingInterface extends Interface2{

static final int a =100;

public int calculateArea();

public void testing1();

}

package com;

public interface Interface2 {
 public void test();
}


package com;

public class TestingImpl implements TestingInterface{

public void test() {
System.out.println("Just testing this method");
}

public int calculateArea() {
int c = this.a*this.a;
System.out.println("The area calculated is "+c);
return c;
}

public void testing1() {
System.out.println("This method is from TestingInterface");
}
public  static void main(String args[])
{
TestingInterface obj = new TestingImpl();
obj.calculateArea();
obj.test();
obj.testing1();
}

}

No comments:

Post a Comment