Question: Problem 2 [ 3 marks ] : Write an inheritance hierarchy for classes Point, Circle and Cylinder. Use point as the super class of the

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 x,y 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
2
 Problem 2[3 marks]: Write an inheritance hierarchy for classes Point, Circle

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!