Problem

Recall the Rectangle and Cube classes discussed earlier, as shown in Figure 10-18....

Recall the Rectangle and Cube classes discussed earlier, as shown in Figure 10-18.

a) Is the following statement legal or illegal? If it is illegal, why? Rectangle r = new Cube(10, 12, 5);

b) If you determined that the statement in part a is legal, are the following statements legal or illegal? (Indicate legal or illegal for each statement.)

System.out.println(r.getLength());

System.out.println(r.getWidth());

System.out.println(r.getHeight());

System.out.println(r.getSurfaceArea());

c) Is the following statement legal or illegal? If it is illegal, why? Cube c = new Rectangle(10, 12);

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT