Question: 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
 Solve it using JAVA Problem 2[3 marks]: Write an inheritance hierarchy

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem in Java you need to create an inheritance hierarchy with three classes Point Circle and Cylinder Heres the code java class Point ... View full answer

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!