Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You just have to answer R-2.13 , but if you want to show your work for R-2.12 as well, go ahead and do it. Thanks!

You just have to answer R-2.13, but if you want to show your work for R-2.12 as well, go ahead and do it. Thanks!

R-2.12 Draw a class inheritance diagram for the following set of classes: Class Goat extends Object and adds an instance variable tail and methods milk( ) and jump( ). Class Pig extends Object and adds an instance variable nose and methods eat(food) and wallow( ). Class Horse extends Object and adds instance variables height and color, and methods run( ) and jump( ). Class Racer extends Horse and adds a method race( ). Class Equestrian extends Horse and adds instance variable weight and is- Trained, and methods trot( ) and isTrained( ).

R-2.13 Consider the inheritance of classes from Exercise R-2.12, and let d be an object variable of type Horse. If d refers to an actual object of type Equestrian, can it be cast to the class Racer? Why or why not?

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

2. Enrolling employees in courses and programs.

Answered: 1 week ago

Question

1. Communicating courses and programs to employees.

Answered: 1 week ago