Draw and annotate a class hierarchy that represents various types of animals in a zoo. Show what characteristics would be represented in the various classes of the hierarchy. Explain how polymorphism could play a role in guiding the feeding of the animals.

What will be an ideal response?




The abstract method feedingInstructions is established in the ZooAnimal class, ensuring that child classes will implement it. That way, each class can have a definition of feedingInstructions that makes sense for it. A program that manages a list of various animal objects could then print feeding instructions for all animals by making a polymorphic call to feedingInstructions for each animal.

Computer Science & Information Technology

You might also like to view...

Explain why the log buffer need not be flushed when an abort record is appended to it.

What will be an ideal response?

Computer Science & Information Technology

A paragraph style can be applied to only a portion of a paragraph

Indicate whether the statement is true or false

Computer Science & Information Technology

Results on the first page of a search engine earn more than ____________________ percent of all traffic from the average web search.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Answer the following statements true (T) or false (F)

1) Syntax errors cause a program to fail and terminate prematurely. 2) Variables that store totals should generally be initialized to zero before being used in a program. 3) A variable used only within a repetition statement should be declared within the statement. 4) int division may yield a non-int result.

Computer Science & Information Technology