class InterfaceImp2 implements a2.Action{double num = 50;public void addValue(int n){num += (n+1)*n/2;}public void subtractValue(int n){num -= (n+1)*n/2;}public void factorialValue(int n){num = 1;for(int i =1;i{num *= i;}}public double getValue(){return num;}}public class InterfaceTest{public static void main(String args[]){double i;a2.InterfaceImp1 classObj1 = new a2.InterfaceImp1();i = classObj1.getValue();System.out.println("The original value in InterfaceImp1 is:"+i);if(i{classObj1.addValue(20);i = classObj1.getValue();System.out.println("After call addValue method, value of InterfaceImp1 is:"+i);}else{classObj1.subtractValue(30);i = classObj1.getValue();System.out.println("After call subtractValue method, value of InterfaceImp1 is:"+i);}classObj1.factorialValue(6);i = classObj1.getValue();System.out.println("After call factorialValue method, value of InterfaceImp1 is:"+i);InterfaceImp2 classObj2 = new InterfaceImp2();i = classObj2.getValue();System.out.println("The original value of InterfaceImp2 is:"+i);if(i{classObj2.addValue(40);i = classObj2.getValue();System.out.println("After call addValue method, value of InterfaceImp2 is:"+i);}else{classObj2.subtractValue(40);i = classObj2.getValue();System.out.println("After call subtractValue method, value of InterfaceImp2 is:"+i);}classObj2.factorialValue(8);i = classObj2.getValue();System.out.println("After call factorialValue method, value of InterfaceImp2 is:"+i);}}