OOPortal
SiteMap
Building C++ Classes
Programming C++
Constructor Functions
«Prev
Next»
Building C++ Classes
OOP Encapsulation
OOP Encapsulation - Quiz
Black Box Principle
Class vs. Struct
C++ Class Constructs
Scope Resolution Operator
Unary Form Scope Resolution
Binary Scope Resolution
Orthogonal Class Design
Overloading Member Functions
External Member Functions
Constructor Functions
Constructor Initializer List
Cplus Constructor - Quiz
Dynamic Stack
Default Copy Constructors
C++ Constructor - Quiz
Each question is worth one point. Select the best answer for each question.
1.
A constructor's chief purpose is to:
Please select the best answer.
A.
allocate any array whose size is given as a constant
B.
initialize class variables
C.
construct a line of output from multiple parameters
D.
all of these
2.
If the class does not provide an explicit constructor:
Please select the best answer.
A.
the compiler generates an error
B.
the compiler generates a default constructor
C.
the compiler initializes all class variables to 0
D.
none of these
3.
A default constructor:
Please select the best answer.
A.
takes no arguments
B.
returns no value
C.
is created for you if you do not specify any constructors
D.
all of these
4.
A constructor initializer:
Please select the best answer.
A.
initializes each data member to 0
B.
initializes data members with the value in parentheses
C.
calls default constructor to initialize each data member
D.
may only be used in a copy constructor
Correct answers:
Your Score: 0
Submit
Quiz Explanation