O'Reilly logo

Learning C# 3.0 by Brian MacDonald, Jesse Liberty

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 8: Inside Methods

Quiz Solutions

Solution to Question 8-1. Method overloading allows the author of the class to create a method with varying input parameters, rather than having to have many methods with different names that serve similar purposes.

Solution to Question 8-2. Overloaded methods must differ in the number of parameters, the parameter types, or both. Simply differing in return type is not an overload.

Solution to Question 8-3. The signature of a method is its name and the types on its parameter list.

Solution to Question 8-4. Properties are public accessors to your encapsulated data. Properties appear to the class creator as methods, but to the class’s clients as fields.

Solution to Question 8-5. Properties enforce encapsulation through data hiding. They isolate the internal members of the class from the client. If you change how the internal values are generated, the property will seem to be unchanged, to outside callers.

Solution to Question 8-6. To create a read-only property, do not implement the set part of the property. No special notation is required.

Solution to Question 8-7. Automatic properties provide a shorter way for you to create a property, if all you need to do is set or retrieve a value.

Solution to Question 8-8. You retrieve multiple return values from a method by passing in parameters by reference and getting the results back in those parameters.

Solution to Question 8-9. If you want to pass a value object (variable) by reference, you use the keyword ...

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