Question: Write a program (Java) that can store information about basketballs. Ball class (Everything is public) radius double color String Ball(radius, color) //one constructor area() //returns

Write a program (Java) that can store information about basketballs.

Ball class (Everything is public)

radius double

color String

Ball(radius, color) //one constructor

area() //returns the area of the ball. Use Math.PI and Math.pow for

//calculating the area

Basketball inherits Ball (Everything is public)

noOfStripes int

Basketball(noOfStripes,radius, color)

Basketball(radius, color) //assign the number 8 as the default value

//for the number of stripes

//use this and super to call the constructors as you see fit

Driver class

Main method

Create two Basketball objects (You can hardcode the basketball data)

basket1 uses the three argument constructor

basket2 uses the two argument constructor

call display method

//note basket1 and basket2 should be local variables

Display method

Call the area method to display the area for each of the balls

Display all the instance variables for each of the objects.

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!