Ch. 10 Flashcards

(20 cards)

1
Q

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.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The compiler will create a default constructor for a class even if you already declared a constructor(s).
True.
False.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The compiler will create a default constructor for a class even if you already declared a constructor(s).
True.
False.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

[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

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Keyword _______ is used to indicate a method overloads a specific operator.
implement
operator
overload
op

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Object orientation uses classes to:
develop algorithms
encapsulate data and methods
organize large amounts of data
None of the above.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Variables or methods declared with access modifier public are accessible wherever the program has a reference to an object of the class.
True.
False.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Only certain objects have a this reference.
True.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How many parameters does the default constructor that C# creates for you have?
3
1
0
varies

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Operators should be overloaded to perform actions similar to those that they normally perform on objects of simple types.
True.
False.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The classes, variables and methods in a program are displayed in a hierarchical structure in Class View.
True.
False.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The purpose of utility methods is to support the operation of a class’ other methods.
True.
False.

17
Q

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.

17
Q

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

18
Q

this is often used to distinguish between a local variable and class variable that share an identical name.
True.
False.