4.1 a) C
. b) class
. c) new
. d) type, name. e) void
. f) instance variable. g) auto-implemented property. h) decimal
. i) Parse
. j) access modifier.
4.2 a) False. By convention, method names begin with an uppercase first letter and all subsequent words in the name begin with an uppercase first letter. b) False. A property’s get
accessor enables a client to retrieve the value of the instance variable associated with the property. A property’s set
accessor enables a client to modify the value of the instance variable associated with the property. c) False. Numeric simple-type instance variables are initialized to 0
, bool
simple-type instance variables are initialized to false
and instance variables of all other types are initialized to null
. d) True. e) True. f) True. g) False. Such variables are called local variables and can be used only in the method in which they’re declared. h) False. A property declaration can contain a get
accessor, a set
accessor or both. i) True. j) False. Instance variables are initialized by default.
4.3 A local variable is declared in the body of a method and can be used only in the method in which it’s declared. An instance variable is declared in a class, but not in the body of any of the class’s members. Every object (instance) of a class has a separate copy of the class’s instance variables. Also, instance variables are accessible to all members of the class. (We’ll see an exception to this in Chapter 10.)
4.4 A parameter represents additional information that a method requires to perform its task. Each parameter required by a method is specified in the method’s declaration. An argument is the actual value that’s passed to a method parameter when a method is called.