Constructor Functions  «Prev  Next»

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