Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Below is the modified code using the extends keyword in Java to implement inheritance The MyCalculat...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started