Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create an abstract class named Container that has one integer attribute named size , and one String attribute named color. It should have a

1. Create an abstract class named Container that has one integer attribute named size, and one String attribute named color.

  • 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.

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.

please do in java, thank you.

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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions