O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required