Question: java program 2. (20 points). Given the following abstract class in the file Shape.java public abstract class Shape { public abstract double arca(); public abstract

2. (20 points). Given the following abstract class in the file Shape.java public abstract class Shape { public abstract double arca(); public abstract double perimeter(); } a. You wish to use this abstract class and use it to generate a class Square. This class should contain an integer instance variable side. This variable must be initialized by a constructor to the integer value 6. Then the arca must be calculated as side and the perimeter must be calculated as 4* side. Finally the area and the perimeter must be printed. b. Write a class TestSquare that makes the needed initializations and prints the following output Square side: 6 Resulting area: 36 Resulting perimeter: 24 c. Given the following program segment: public class Mystery { public static void main(String ( args) { int x = 5; double y = x; int z=y: System.out.println(" x = "+x+"y="+y+" z = "+z); }// end main }// end class Is there an error? If so, correct it and give the output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
