Home > Articles > Programming > C#

This chapter is from the book

Self-Review Exercises


Fill in the blanks in each of the following:

  1. A house is to a blueprint as a(n) _______ is to a class.
  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. By default, classes that are not explicitly declared in a namespace are implicitly placed in the _______.
  6. When each object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n) _______.
  7. C# provides three simple types for storing real numbers—_______, _______ and _______.
  8. Variables of type double represent _______ floating-point numbers.
  9. Convert method _______ returns a decimal value.
  10. Keyword public is a(n) _______.
  11. Return type _______ indicates that a method will not return any information when it completes its task.
  12. Console method _______ reads characters until a newline character is encountered, then returns those characters (not including the newline) as a string.
  13. A(n) _______ is not required if you always refer to a class with its fully qualified class name.
  14. Variables of type float represent _______ floating-point numbers.
  15. The format specifier _______ is used to display values in a monetary format.
  16. Types are either _______ types or _______ types.
  17. For a(n) _______, the compiler automatically generates a private instance variable and set and get accessors.


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. A using directive is not required when one class in a namespace uses another in the same namespace.
  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. After defining a property, you can use it the same way you use a method, but with empty parentheses, because no arguments are passed to a property.
  6. Variables or methods declared with access modifier private are accessible only to methods and properties 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.
  11. Reference-type instance variables are initialized by default to the value null.
  12. Any class that contains public static void Main( string[] args ) can be used to execute an application.
  13. The number of arguments in the method call must match the number of required parameters in the method declaration's parameter list.
  14. Real number values that appear in source code are known as floating-point literals and are of type float by default.


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


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

  • + Share This
  • 🔖 Save To Your Account