Question: a) Given is the program name OurCalculation with class Calculation that perform the addition, subtraction. Using the keywords EXTEND in inheritance, rewrite the code


a) Given is the program name OurCalculation with class Calculation that perform the addition, subtraction. Using the keywords EXTEND in inheritance, rewrite the code so that My Calculation will EXTEND the class Calculation and, In the class, My_Calculation perform the multiplication function. The main method should be modified to display the multiplication result. The output should look like this: The sum of the given numbers:30 The difference between the given numbers: 10 The multiplication of the given numbers:200 Program OurCalculation class Calculation { int z; ** public void addition (int x, int y) { z = x + y; System.out.println("The sum of the given numbers: "+z); } public void Subtraction (int x, int y) { } z = x - y; System.out.println ("The difference between the given } public class My_Calculation { public static void main (String args []) { int a = 20, b = 10; } numbers: "+z); } My_Calculation demo= new My_Calculation (); demo. addition (a, b); demo. Subtraction (a, b);
Step by Step Solution
There are 3 Steps involved in it
Below is the modified code using the extends keyword in Java to implement inheritance The MyCalculat... View full answer
Get step-by-step solutions from verified subject matter experts
