Question: Answer question use object oriented programming in java e) Based on the d) above, assuming that the array has 10 object. calculate and display the

Answer question use object oriented programming in java

Answer question use object oriented programming in java e) Based on the

e) Based on the d) above, assuming that the array has 10 object. calculate and display the average of volume of blue and red cylinder object only.

**please give explanation for your answer..

QUESTION 4 Given the following information of ThreedShape, Sphere and Cylinder classes. The Sphere and Cylinder are subclasses of the ThreeDShape class. Super class : ThreeDShape Attributes : color // "red", "blue" and "yellow" Methods : constructors, mutators, retrievers, printers and processors Subclass : Sphere Attributes : radius Il e.g. 2.5 Methods : constructors, mutators, retrievers, printers and processors Subclass Attributes : Cylinder : radius Il e.g. 2.5 height Il e.g. 10 : constructors, mutators, retrievers, printers and processors Methods a) Draw the class hierarchy diagram to show the relationship between the three classes. (2 marks) b) Declare an abstract method named calcvel() for the Three Shape class to return the value of volume (1 mark) c) Write a method definition of calcvol() for both Sphere and Cylinder classes. The formula for calculating the volume of sphere and cylinder are shown as below: volume of sphere volume of cylinder = r2 h where r is a radius and h is a height. (6 marks) d) Declare an array named mylist with size 10 in order to store 10 objects regardless of the Sphere or Cylinder types (1 mark) 4

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!