Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve it using JAVA Problem 2 [ 3 marks ] : Write an inheritance hierarchy for classes Point, Circle and Cylinder. Use point as the

Solve it using JAVA
Problem 2[3 marks]:
Write an inheritance hierarchy for classes Point, Circle and Cylinder. Use point as the
super class of the hierarchy. Specify the instance variables and methods for each class.
The private instance variables of Point should be x-y coordinates of the point, provide
set and get methods to manipulate the private instance variables. Class Point should
contain a toString method which returns the formatted point coordinates i.e (x,y),
classes Circle and cylinder should inherit class point, class circle will contain radius of
the circle as instance variable it will inherit the x,y instance variables, the constructor of
class Circle should call the base class constructor to initialize xy inherited instance
variables. Also, circle class will contain a method to calculate the area of the circle.
Moreover, class circle will provide an overridden version of method toString, there will
be a call of the superclasse's toString method to do a part of the work. Class cylinder
will do the same as described for the Circle class. In addition, it will have an instance
variable height. Moreover, class Cylinder must contain a method to calculate the volume
of the Cylinder object. Write a program that instantiates objects of your classes and
outputs the area of the circle and cylinder objects.
The following is a sample input/output
8 coordinate is 37
4 coordinate is 43
Radius is 2.5
The neu location and radius of circle areCenter =[2,2];
Radius =4.25
Area is 56.745017305465645
8 coordinate is 12
coordinate is 23
Radius is 2.5
Height is 5.7
The neu location, radius and height of cylinder are
Center =[2,2]
Radius =4.25; Height =10.0
hadius =4.25; Height =1
Jolune is 56?.4561730546565
Press any key to continueSol
image text in transcribed

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

What is the KPI target value for average sales?

Answered: 1 week ago