Question: Test 4(30 points) Inheritance and Polymorphism. 1. (5 points)Design an interface named Colorable with a void method named howToColor0. Every class of a Colorable object

 Test 4(30 points) Inheritance and Polymorphism. 1. (5 points)Design an interface

Test 4(30 points) Inheritance and Polymorphism. 1. (5 points)Design an interface named Colorable with a void method named howToColor0. Every class of a Colorable object must implement the interface Colorable. 2. (10 points)Design a class named Rectangle implementing Colorable. Implement howToColor0 to display the message "Color all for sides.". a) Declare two instance variables: width and height. b) Overload constructors. c) Override the method howToColor0. 3. (10 points) Design a class named Circle implementing Colorable. Implement howToColor0 to display the message "Color its arc.". a) Declare its property representing its radius. b) Define a method getArea() which returns its area(Suppose pi =3.14 ). c) Override the method howToColor0. 4. (5 points) Write a program to test whether all of subclasses meet the requirements a) Declare a variable of Colorable to refer to the object of Rectangle or Circle b) Create an object of Rectangle c) Create an object of Circle d) Invoke their method howToColor(0 e) Invoke the method getArea(), and show the area on console

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!