Deck 10: Classes: a Deeper Look, Part 2

Full screen (f)
exit full mode
Question
Inside a function definition for a member function of an object with data element x, which of the following is not equivalent to this->x:

A) *this.x
B) *this).x
C) x
D) * & *this) ) ).x
Use Space or
up arrow
down arrow
to flip the card.
Question
If Americans are objects of the same class, which of the following attributes would most likely be represented by a static variable of that class?

A) Age.
B) The President.
C) Place of birth.
D) Favorite food.
Question
When composition one object having another object as a member) is used:

A) The host object is constructed first and then the member objects are placed into it.
B) Member objects are constructed first, in the order they appear in the host constructor's initializer list.
C) Member objects are constructed first, in the order they are declared in the host's class.
D) Member objects are destructed last, in the order they are declared in the host's class.
Question
Static member functions:

A) Can use the this pointer.
B) Can access only other static member functions and static data members.
C) Cannot be called until an object of their class is instantiated.
D) Can be declared const as well.
Question
Which of the following are true about an abstract data type?
I) Captures a data representation.
II) Defines the operations that are allowed on its data.
III) Replaces structured programming.

A) I, II and III.
B) I and II.
C) I and III.
D) II and III.
Question
Which of the following is not true about friend functions and friend classes?

A) A class can either grant friendship to or take friendship from another class using the friend keyword.
B) A friend declaration can appear anywhere in a class definition.
C) A friend of a class can access all of its private data member and member functions.
D) The friendship relationship is neither symmetric nor transitive.
Question
An error occurs if:

A) A non-reference, non-const, primitive data member is initialized in the member initialization list.
B) An object data member is not initialized in the member initialization list.
C) An object data member does not have a default constructor.
D) An object data member is not initialized in the member initialization list and does not have a default constructor.
Question
The numbers 3, 2, 5, 7 are enqueued in a queue in that order, then three numbers are dequeued, and finally 3, 7, 9, 4 are enqueued in that order. What is the first number in the queue the next number to be dequeued)?

A) 3
B) 7
C) 9
D) 4
Question
Assume that t is an object of class Test, which has member functions a), b), c) and d). If the functions a), b) and c) all return references to an object of class Test using the dereferenced this pointer) and function d) returns void, which of the following statements will not produce a syntax error:

A) t.a).b).d);
B) a).b).t;
C) t.d).c);
D) t.a).t.d);
Question
For a non-constant member function of class Test, the this pointer has type:

A) const Test *
B) Test * const
C) Test const *
D) const Test * const
Question
Which of the following statements will not produce a syntax error?

A) Defining a const member function that modifies a data member of the object.
B) Invoking a non-const member function on a const object.
C) Declaring an object to be const.
D) Declaring a constructor to be const.
Question
Which of the following is not an abstract data type?

A) An int.
B) A user-defined class.
C) A for loop.
D) None of the above are abstract data types.
Question
Increment i )
{
Count = c;
}
Does not cause any compilation errors. This tells you that:

A) count must be a non-const variable.
B) count must be a const variable.
C) increment must be a non-const variable.
D) increment must be a const variable.
Question
If the line:
Friend class A;
Appears in class B, and the line:
Friend class B;
Appears in class C, then:

A) Class A is a friend of class C.
B) Class A can access private variables of class B.
C) Class C can call class A's private member functions.
D) Class B can access class A's private variables.
Question
Static data members of a certain class:

A) Can be accessed only if an object of that class exists.
B) Cannot be changed, even by objects of the same that class.
C) Have class scope.
D) Can only be changed by static member functions.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/15
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Classes: a Deeper Look, Part 2
1
Inside a function definition for a member function of an object with data element x, which of the following is not equivalent to this->x:

A) *this.x
B) *this).x
C) x
D) * & *this) ) ).x
A
2
If Americans are objects of the same class, which of the following attributes would most likely be represented by a static variable of that class?

A) Age.
B) The President.
C) Place of birth.
D) Favorite food.
B
3
When composition one object having another object as a member) is used:

A) The host object is constructed first and then the member objects are placed into it.
B) Member objects are constructed first, in the order they appear in the host constructor's initializer list.
C) Member objects are constructed first, in the order they are declared in the host's class.
D) Member objects are destructed last, in the order they are declared in the host's class.
C
4
Static member functions:

A) Can use the this pointer.
B) Can access only other static member functions and static data members.
C) Cannot be called until an object of their class is instantiated.
D) Can be declared const as well.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following are true about an abstract data type?
I) Captures a data representation.
II) Defines the operations that are allowed on its data.
III) Replaces structured programming.

A) I, II and III.
B) I and II.
C) I and III.
D) II and III.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the following is not true about friend functions and friend classes?

A) A class can either grant friendship to or take friendship from another class using the friend keyword.
B) A friend declaration can appear anywhere in a class definition.
C) A friend of a class can access all of its private data member and member functions.
D) The friendship relationship is neither symmetric nor transitive.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
7
An error occurs if:

A) A non-reference, non-const, primitive data member is initialized in the member initialization list.
B) An object data member is not initialized in the member initialization list.
C) An object data member does not have a default constructor.
D) An object data member is not initialized in the member initialization list and does not have a default constructor.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
8
The numbers 3, 2, 5, 7 are enqueued in a queue in that order, then three numbers are dequeued, and finally 3, 7, 9, 4 are enqueued in that order. What is the first number in the queue the next number to be dequeued)?

A) 3
B) 7
C) 9
D) 4
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
9
Assume that t is an object of class Test, which has member functions a), b), c) and d). If the functions a), b) and c) all return references to an object of class Test using the dereferenced this pointer) and function d) returns void, which of the following statements will not produce a syntax error:

A) t.a).b).d);
B) a).b).t;
C) t.d).c);
D) t.a).t.d);
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
10
For a non-constant member function of class Test, the this pointer has type:

A) const Test *
B) Test * const
C) Test const *
D) const Test * const
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following statements will not produce a syntax error?

A) Defining a const member function that modifies a data member of the object.
B) Invoking a non-const member function on a const object.
C) Declaring an object to be const.
D) Declaring a constructor to be const.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following is not an abstract data type?

A) An int.
B) A user-defined class.
C) A for loop.
D) None of the above are abstract data types.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
13
Increment i )
{
Count = c;
}
Does not cause any compilation errors. This tells you that:

A) count must be a non-const variable.
B) count must be a const variable.
C) increment must be a non-const variable.
D) increment must be a const variable.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
14
If the line:
Friend class A;
Appears in class B, and the line:
Friend class B;
Appears in class C, then:

A) Class A is a friend of class C.
B) Class A can access private variables of class B.
C) Class C can call class A's private member functions.
D) Class B can access class A's private variables.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
15
Static data members of a certain class:

A) Can be accessed only if an object of that class exists.
B) Cannot be changed, even by objects of the same that class.
C) Have class scope.
D) Can only be changed by static member functions.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 15 flashcards in this deck.