Filters
Question type

Study Flashcards

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.

E) B) and D)
F) A) and D)

Correct Answer

verifed

verified

B

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.

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

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) ;

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

A

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.

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

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

E) C) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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.

E) A) and C)
F) B) and D)

Correct Answer

verifed

verified

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.

E) B) and C)
F) C) and D)

Correct Answer

verifed

verified

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.

E) B) and D)
F) A) and B)

Correct Answer

verifed

verified

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

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

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.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

B

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

E) All of the above
F) A) and C)

Correct Answer

verifed

verified

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.

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

Showing 1 - 15 of 15

Related Exams

Show Answer