Question: Q6. Write a program to create an abstract class called Shape that stores the dimensions of a three- dimensional object. It also defines a parameterized

 Q6. Write a program to create an abstract class called Shape

Q6. Write a program to create an abstract class called Shape that stores the dimensions of a three- dimensional object. It also defines a parameterized constructor, and an abstract method called area() that returns the area of an object. The program derives two subclasses from Shape. The first is Rectangle and the second is Triangle. Override the method area() so that it returns the area of a rectangle and a triangle respectively. Supply a test program that uses polymorphism to test these classes and methods

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!