Self-Review Exercises

  1. 4.1 Fill in the blanks in each of the following:

    1. The format specifier                 is used to display values in a monetary format.

    2. Every class declaration contains keyword                 followed immediately by the class’s name.

    3. Operator                 creates an object of the class specified to the right of the keyword.

    4. Each parameter must specify both a(n)                 and a(n)                .

    5. Return type                 indicates that a method will not return any information when it completes its task.

    6. When each object of a class maintains its own copy of an attribute, the attribute is known as a(n)                .

    7. For a(n)                , the compiler automatically generates a private instance variable and set and get accessors.

    8. Variables of type                 are typically used to represent monetary amounts.

    9. decimal method                 converts a string to a decimal value.

    10. Keyword public is a(n)                .

  2. 4.2 State whether each of the following is true or false. If false, explain why.

    1. By convention, method names begin with a lowercase first letter and all subsequent words in the name begin with a capital first letter.

    2. A property’s get accessor enables a client to modify the value of the instance variable associated with the property.

    3. All instance variables are initialized by default to null.

    4. Empty parentheses following a method name in a method declaration indicate that the method does not require any parameters to perform its task.

    5. The number of arguments in the method call must match the number of required parameters in the method declaration’s parameter list.

    6. Variables or methods declared with access modifier private are accessible only to members of the class in which they’re declared.

    7. Variables declared in the body of a particular method are known as instance variables and can be used in all methods of the class.

    8. A property declaration must contain both a get accessor and a set accessor.

    9. The body of any method or property is delimited by left and right braces.

    10. Local variables are initialized by default.

  3. 4.3 What is the difference between a local variable and an instance variable?

  4. 4.4 Explain the purpose of a method parameter. What is the difference between a parameter and an argument?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset