Question: Please, answer the question 4 Test 4(30 points) Inheritance and Polymorphism. 1. (5 points)Design an interface named Colorable with a void method named howToColor0. Every

Please, answer the question 4 Test 4(30 points) Inheritance and Polymorphism. 1.Please, answer the question 4

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 howTo Color 0 to display the message "Color all for sides." a) Declare two instance variables: width and height. b) Overload constructors. c) Override the method how ToColor0. 3. (10 points) Design a class named Circle implementing Colorable. Implement how To Color0 to display the message "Color its arc.". a) Declare its property representing its radius. b) Define a method getArea0 which returns its area(Suppose pi =3.14 ). c) Override the method howTocolor 0 . 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 howTocolor0 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!