Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Database And Knowledge Base Systems

Authors: S Krishna

1st Edition

9810206208, 978-9810206208

More Books

Students also viewed these Databases questions

Question

What items should be included in the audit status report?

Answered: 1 week ago

Question

Organize and support your main points

Answered: 1 week ago

Question

Move smoothly from point to point

Answered: 1 week ago

Question

Outlining Your Speech?

Answered: 1 week ago