Question: In Java, Implement the Shape hierarchy in Fig. 1. 1. Shape needs to be implemented as an abstract class. 2. Each Two Dimensional Shape should
In Java,

Implement the Shape hierarchy in Fig. 1.
1. Shape needs to be implemented as an abstract class.
2. Each Two Dimensional Shape should contains method getArea() to calculate the area of the two-dimensional shape.
3. Each Three Dimensional Shape should contains method getArea() and getVolume() to calculate the surface area and volume, respectively, of the three-dimensional shape.
4. Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy.
Print a text description of the object to which each array element refers.
All the shapes in the array are needed to be processed
determine whether a shape is a TwoDimensionalShape or a ThreeDimensionalShape
if it is a TwoDimensionalShape, display its area;
if it is a TwoDimensionalShape, display its area and volumn.
Thank you in advance!
Shape TwoDimensionalShape ThreeDimensionalShape Cirele Square Triangle Sphere Cube Tetrahedron Fig. 1. Shape Hierarchy
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
