Question: 2. Write a program in Java to perform the following tasks: a. Create an abstract class called VolumeCalculator with attribute radius and height, and a

2. Write a program in Java to perform the following tasks: a. Create an abstract class called VolumeCalculator with attribute radius and height, and a final field PI whose value is 3.14. b. Add abstract methods volume() and print() to the VolumeCalculator class. c. Create subclasses called Cone and Cylinder of the VolumeCalculator class. Add a field coneVolume and cylinderVolume in Cone and Cylinder class respectively to store the volume. d. Implement the method volume() in Cone and Cylinder to find the volume of Cone and Cylinder.(Hint : Formula for cone volume is 1/3 P radius*radius*height and cylinder is PI*radius*radius*height ) e. Implement the method print() in Cone and Cylinder class that displays radius, height, and volume. Use superclass reference variable to call the subclass versions of volume() and print() methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
