Ch. 10 Flashcards
(20 cards)
C# invokes the appropriate constructor by matching the number, types and order of the parameters in the constructor call to those in each constructor definition.
True.
False.
The compiler will create a default constructor for a class even if you already declared a constructor(s).
True.
False.
The compiler will create a default constructor for a class even if you already declared a constructor(s).
True.
False.
[C#6] It’s common to include in an exception’s error message a variable’s or property’s identifier. This information can help a client-code programmer understand the context in which the exception occurred. Prior to C# 6, you had to hard code these identifiers into your error-message strings. As of C# 6, you can instead use the ________ operator, which returns a string representation of the identifier enclosed in parentheses.
valueof
stringof
characterof
nameof
Keyword _______ is used to indicate a method overloads a specific operator.
implement
operator
overload
op
Object orientation uses classes to:
develop algorithms
encapsulate data and methods
organize large amounts of data
None of the above.
Variables or methods declared with access modifier public are accessible wherever the program has a reference to an object of the class.
True.
False.
Only certain objects have a this reference.
True.
How many parameters does the default constructor that C# creates for you have?
3
1
0
varies
Which statement is false?
The actual data representation used within the class is of no concern to the class’s clients.
Clients generally care about what the class does but not how the class does it.
Clients are usually involved in a class’s implementation.
Hiding the implementation reduces the possibility that other program parts will become dependent on class-implementation details.
Which statement is false?
The compiler always creates a default constructor for a class.
If a class has constructors, but none of the public constructors are parameterless, and a program attempts to call a parameterless constructor to initialize an object of the class, a compilation error occurs.
A constructor can be called with no arguments only if the class does not have any constructors or if the class has a public parameterless constructor.
Parameterless constructors do not have any arguments.
Operators should be overloaded to perform actions similar to those that they normally perform on objects of simple types.
True.
False.
Having a this reference allows:
A method to refer explicitly to the instance variables and other methods of the object on which the method was called.
A method to refer implicitly to the instance variables and other methods of the object on which the method was called.
An object to reference itself.
All of the above.
The classes, variables and methods in a program are displayed in a hierarchical structure in Class View.
True.
False.
Composition:
Is a form of software reuse.
Is using an object reference as a class member.
Is a good design practice.
All of the above.
The purpose of utility methods is to support the operation of a class’ other methods.
True.
False.
At least one argument of an operator overload method must be a reference to an object of the class in which the operator is overloaded.
True.
False.
When should a program explicitly use the this reference?
accessing a private variable
accessing a public variable
accessing a local variable
accessing a field that is shadowed by a local variable
this is often used to distinguish between a local variable and class variable that share an identical name.
True.
False.