Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+7 How has the COVID-19 pandemic impacted the operations of IHRM?

Answered: 1 week ago

Question

CFD is highly risky. Do you agree? Give reasons for your answer.

Answered: 1 week ago

Question

Describe the types of power that effective leaders employ

Answered: 1 week ago

Question

Describe how leadership styles should be adapted to the situation

Answered: 1 week ago