IntBinaryOperation

Report a typo

You are given an abstract class IntBinaryOperation. It has one abstract method perform() and two fields representing the operation arguments. The fields are initialized in the constructor. See the provided code template.

You need to declare and implement two classes representing concrete operations: Addition and Multiplication. The classes must extend the abstract class and implement the method perform(). The implementations should work in accordance with the class name. Do not forget to write two-argument constructors in your classes.

Do NOT make your classes public.

Write a program in Java 17
abstract class IntBinaryOperation {

protected int firstArg;
protected int secondArg;

public IntBinaryOperation(int firstArg, int secondArg) {
this.firstArg = firstArg;
this.secondArg = secondArg;
}

public abstract int perform();
}

// declare and implement your classes here
___

Create a free account to access the full topic