Define an interface named shape with a single method named


Question: Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area (); Next, define a class named Circle that implements Shape. The Circle class should have an instance variable for the radius, a constructor that sets the radius, accessor/ mutator methods for the radius, and an implementation of the area method. Also define a class named Rectangle that implements Shape. The Rectangle class should have instance variables for the height and width, a constructor that sets the height and width, accessor and mutator methods for the height and width, and an implementation of the area method.

The following test code should then output the area of the Circle and Rectangle objects:

1188_17.png

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Define an interface named shape with a single method named
Reference No:- TGS02404867

Now Priced at $10 (50% Discount)

Recommended (95%)

Rated (4.7/5)