Question: 5. Shape hierarchy is depicted as follows: Shape Circle Square Attribute and methods: public abstract class Shape Description Attribute private String color constructor public Shape(

 5. Shape hierarchy is depicted as follows: Shape Circle Square Attribute

and methods: public abstract class Shape Description Attribute private String color constructor

5. Shape hierarchy is depicted as follows: Shape Circle Square Attribute and methods: public abstract class Shape Description Attribute private String color constructor public Shape( String col) method public void setColor( String col ) public String getColor) ract double computeAreal) calculate the area of Shape object public class Circle extends Shape Attributeprivate double radius constructor public Circle( String col, double rad ) method public void setRadius( double rad) if l( rad >= 0.0 ), throw new IllegalArgumentException _public double getRadius() public double computeArea() using @override public class Square extends Shape private double length constructor public Square( String col, double len ) Attribute public void setlength double len) public double getlengthl public double computeArea() if !( rad >= 0.0 ), throw new IllegalArgumentException method using @override A) Define an abstract superclass Shape and subclass Circle and subclass Square according to the above information (B) Write class ShapeSystem Test Red and radius-8.50 (a) create a Circle object, cir1 with color create a Circle object, cir2 with color Green and radius 16.75 (g) create a Square object, squ1 with color - Yellow and length 10.00 (d) create a Square object, squ2 with color Blue and length - 15.00 (e) display the color and area (with precision 2) of each object on the screen frcreate a 4 element Shapel] shapes assign the references of cir1, cir2, squ1 and squ2 to Shapelo], Shapel1], Shape[2] and Shape 3]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!