Chapter 17

Answers to Chapter 17 Review Questions

1: Consider an Animal class from which the Dog, Cat, and Duck classes are derived. Suppose that any Animal can make a sound. Where would you locate the Sound method? Would you provide an implementation for this method or declare it abstract? Why?
A1: The Sound method should be positioned in the Animal class because any animal can make a sound. We don't know the sound an Animal makes (it could be meow, vrooff, or something else), so Sound should be declared abstract in Animal.
2: If the Sound method of the Animal class was declared abstract, would you be able to instantiate an object from this class? Why or why not?
A2: No. The Animal class must be declared abstract because it contains the abstract ...

Get C# Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.