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

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?
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?
3:You want to implement a Sound method in each of Animal's three subclasses and call these three methods polymorphically. Which keywords would you use to declare the Sound method in Animal and in the three subclasses to allow this scenario to take place? Write the method headers in the Animal class and the three subclasses.
4:What's wrong with the following ...

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