Question

Assume that Shape is an interface. Variable shape is defined to be of type Shape. An...

Assume that Shape is an interface. Variable shape is defined to be of type Shape. An assignment statement has variable shape on the left hand side. Assume that classes Circle and Rectangle both implement interface Shape. Describe what kind of objects can be assigned to variable shape on the right-hand side of the assignment statement?

Shape shape;

shape = _____???______

Homework Answers

Answer #1

Any concrete classes that implement an interface I, exhibit an is-a relationship with the interface (similar to the is-a relationship with parent classes).

Thus, here each of class Circle and Rectangle is-a Shape.

Thus,

On the right side, any/all instance(s) of Circle/Rectangle can be written.

Example :

Circle c = new Circle();

Rectangle r = new Rectangle();

Shape s = null;

s = c;                          // valid

s = r;                          // valid

s = new Rectangle(); // valid

s = new Circle();        // valid

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Implement the Shape hierarchy -- create an abstract class called Shape, which will be the parent...
Implement the Shape hierarchy -- create an abstract class called Shape, which will be the parent class to TwoDimensionalShape and ThreeDimensionalShape. The classes Circle, Square, and Triangle should inherit from TwoDimensionalShape, while Sphere, Cube, and Tetrahedron should inherit from ThreeDimensionalShape. Each TwoDimensionalShape should have the methods getArea() and getPerimeter(), which calculate the area and perimeter of the shape, respectively. Every ThreeDimensionalShape should have the methods getArea() and getVolume(), which respectively calculate the surface area and volume of the shape. Every...
1. True or False: If a person has type AB blood, it means that surface antigens...
1. True or False: If a person has type AB blood, it means that surface antigens A and B are not present on the cell membranes of red blood cells. 2. True or False: If compatible blood types are mixed, agglutination will occur. 3. The ___________________ are white blood cells that can differentiate into macrophages. 4. What term best describes the shape of a red blood cell? 5. What component of the formed elements has an important role in the...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
Question 1 The study of Uniform Circular Motion relates to objects traveling with constant speed around...
Question 1 The study of Uniform Circular Motion relates to objects traveling with constant speed around a circle with radius, R. Since the object has a constant speed along a circular path, we can also say that A) the object has zero velocity. B) the object has a constant acceleration magnitude. C) the object has zero acceleration. D) the object has a constant velocity. E) the object has an increasing acceleration. Question 2 Uniform Circular Motion (UCM) problems are just...
a. Describe a Normal Distribution of a variable. b. Where in nature can you find a...
a. Describe a Normal Distribution of a variable. b. Where in nature can you find a Normal Distribution? c. What are the characteristics of a Normal Distribution? d. What are the parameters of a Normal Distribution? d. What information can you determine from a normal distribution? In each of the following Exercises 6.4-6.11, assume that the variable under consideration has a density curve. Note that the answers required here may be only approximately correct. 6.4 The percentage of all possible...
Question 3: Independent-Samples t-Test Group Statistics type of school N Mean Std. Deviation Std. Error Mean...
Question 3: Independent-Samples t-Test Group Statistics type of school N Mean Std. Deviation Std. Error Mean reading score public 168 51.8452 10.42279 .80414 private 32 54.2500 9.19677 1.62578 Independent Samples Test Levene's Test for Equality of Variances t-test for Equality of Means F Sig. t df Sig. (2-tailed) Mean Difference Std. Error Difference 95% Confidence Interval of the Difference Lower Upper reading score Equal variances assumed .564 .453 -1.217 198 .225 -2.40476 1.97519 -6.29986 1.49034 Equal variances not assumed -1.326...
Find the 2016 Basic Financial Report for the City of Maumee before you begin this assignment....
Find the 2016 Basic Financial Report for the City of Maumee before you begin this assignment. Go to www.maumee.org Click on the "City Departments" green button on the left side of the page. Select "Finance" from the list on the left and then “Annual Report” from the drop down box. Click on "2016 Basic Financial Report" under the Current Reports Heading on the right. QUESTION 1 Fiscal accountability can best be assessed by which of these financial statements? Statement of...
MATH125: Unit 1 Individual Project Answer Form Mathematical Modeling and Problem Solving ALL questions below regarding...
MATH125: Unit 1 Individual Project Answer Form Mathematical Modeling and Problem Solving ALL questions below regarding SENDING A PACKAGE and PAINTING A BEDROOM must be answered. Show ALL step-by-step calculations, round all of your final answers correctly, and include the units of measurement. Submit this modified Answer Form in the Unit 1 IP Submissions area. All commonly used formulas for geometric objects are really mathematical models of the characteristics of physical objects. For example, a basketball, because it is a...
Check clearing and the use of float Float is defined as the difference between the balance...
Check clearing and the use of float Float is defined as the difference between the balance shown on the books and the balance in the bank account. A lag often occurs between the time receipts and disbursements are recorded on the company’s books and when the transactions clear the bank. Consider the following scenario: The difference between the balance shown on Destin Co.’s books and the balance shown on its bank statement is $40,000. What type of float does this...
You are asked to implement a C++ class to model a sorted array of unsigned integers....
You are asked to implement a C++ class to model a sorted array of unsigned integers. The class is to be used in an embedded application that cannot assume the presence of the STL. The array has to be dynamically allocated in such a way that allows programmers using it to specify the required size. Your class should should: (1) provide the appropriate constructors and destructor; (2) provide methods for updating, and showing numbers in/to the array (e.g., to be...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT