(COP 3330) Midterm 1 Exam with
complete solutions latest version
A(n) _______ function has access to both public and private members of a class but is
NOT a member function.
a. explicit
b. protected
c. static
d. friend - CORRECT ANSWER-d. friend
Classes encapsulate two types of members: function members that define business
logic and ______ members that define the state of a class.
a. data
b. function
c. construction
d. protected - CORRECT ANSWER-a. data
_______ is a keyword used to ensure that conversion constructors are NOT used
implicitly.
a. static
b. private
c. explicit
d. friend - CORRECT ANSWER-c. explicit
The _______ operator is used to link a member function to a class.
a. +=
b. ::
c. ;
d. == - CORRECT ANSWER-b. ::
The _____ design methodology is used when creating a C++ program or class.
BRAINSCAPE1
, BRAINSCAPE1
a. DUD
b. DDU
c. UUD
d. UDD - CORRECT ANSWER-b. DDU (Declare, Define, Use)
When creating an operator override, the keyword _______ is used to name the
implementation method:
a. operator
b. friend
c. implicit
d. explicit - CORRECT ANSWER-a. operator
The name of a destructor must begin with the special character:
a. '
b. `
c. ~
d. ^ - CORRECT ANSWER-c. ~
++ is a(n) ________ operator.
a. Tertiary
b. Binary
c. Unary
d. *this is the wrong answer* - CORRECT ANSWER-c. Unary
A(n) ________ is used to set constant data members of a class:
a. Initialization list
b. Conversion
c. Cast
d. Initializer - CORRECT ANSWER-a. Initialization list
The keyword "friend" is used in a function's:
a. Definition
b. Declaration
c. Implementation
d. Include - CORRECT ANSWER-b. Declaration
Conversion constructors can accept multiple parameters. (T/F) - CORRECT ANSWER-
F (can only have one parameter, its the type its converting from)
Destructors accept only one parameter. (T/F) - CORRECT ANSWER-F (accept no
parameters)
A class can have only one implementation of an override for a given operator. (T/F) -
CORRECT ANSWER-T (A friend and member function for the same operator overload,
can't do)
BRAINSCAPE1