Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java: #1. Create an abstract class named Container that has one integer attribute named size , and one String attribute named color. [8 points]

In java:

#1. Create an abstract class named Container that has one integer attribute named size, and one String attribute named color. [8 points]

  • It should have a method called getSize() and getColor() that return the size and color of the container respectively.
  • It should also have an abstract method named getVolume() that returns a double.

#2 and #3. Create a child class named Bowl and a child class named Cube. [10 + 10 = 20 points]

The size attribute will refer to the diameter of the bowl and to the side of the cube. (No need to do anything, just understand the significance of the size attribute would imply the diameter and side of the bowl and cube respectively).

(Optional) You may add any attributes or methods to the child classes that are needed.

(Required) Both child classes should at-least have methods as shown below:

  • Constructor with parameters
  • getVolume()
  • equals()
  • toString()

#4. Create an application called ContainerTest that will create an array of Container type. Then, create a few (no less than 2) Bowl and Cube objects and have each array element refer to one such object.

Process the array of those Containers in one loop polymorphically by calling the getVolume() method and use it to output to the console their respective volumes.

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

Question What is an educational benefit trust and how is it used?

Answered: 1 week ago

Question

Question How are VEBA assets allocated when a plan terminates?

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago