C C — Learn

C Programming -Constructors and Destructors

Review each question and reveal answers to strengthen your understanding

1 A constructor that accepts __________ parameters is called the default constructor.
✅ Correct Answer: 3
2 What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?
✅ Correct Answer: 1
3 Destructor has the same name as the constructor and it is preceded by ______ .
✅ Correct Answer: 3
4 For automatic objects, constructors and destructors are called each time the objects
✅ Correct Answer: 1
5 Which constructor function is designed to copy objects of the same class type?
✅ Correct Answer: 4
6 Which of the following statement is correct?
✅ Correct Answer: 3
7 Which of the following statement is incorrect?
✅ Correct Answer: 4
8 When are the Global objects destroyed?
✅ Correct Answer: 2
9 Copy constructor must receive its arguments by __________ .
✅ Correct Answer: 3
10 A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.
✅ Correct Answer: 2
11 A union that has no constructor can be initialized with another union of __________ type.
✅ Correct Answer: 2
12 Which of the following gets called when an object goes out of scope?
✅ Correct Answer: 2
13 Which of the following statement is correct?
✅ Correct Answer: 4
14 ________ used to make a copy of one class object from another class object of the same class type.
✅ Correct Answer: 2
15 Constructors __________ to allow different approaches of object construction.
✅ Correct Answer: 2
16 Which of the following statement is correct?
✅ Correct Answer: 1
17 Which of the following cannot be declared as virtual?
✅ Correct Answer: 4
18 If the copy constructor receives its arguments by value, the copy constructor would
✅ Correct Answer: 3
19 Which of the following are NOT provided by the compiler by default?
✅ Correct Answer: 4
20 It is a __________ error to pass arguments to a destructor.
✅ Correct Answer: 3
21 If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor?
✅ Correct Answer: 2
22 A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values
✅ Correct Answer: 1
23 How many default constructors per class are possible?
✅ Correct Answer: 1
24 Which of the following statement is correct about destructors?
✅ Correct Answer: 3
25 Which of the following statement is correct?
✅ Correct Answer: 1
26 Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?
✅ Correct Answer: 4
27 A destructor takes __________ arguments.
✅ Correct Answer: 4
28 Destructor calls are made in which order of the corresponding constructor calls?
✅ Correct Answer: 1
29 Which of the following never requires any arguments?
✅ Correct Answer: 3
30 A class's __________ is called when an object is destroyed.
✅ Correct Answer: 2
31 Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.
✅ Correct Answer: 3
32 Which of the following statement is correct?
✅ Correct Answer: 4
33 Which of the following statements are correct?
✅ Correct Answer: 2
34 How many times a constructor is called in the life-time of an object?
✅ Correct Answer: 1
35 Which of the following gets called when an object is being created?
✅ Correct Answer: 1
36 To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .
✅ Correct Answer: 3
37 Which of the following statement is correct about constructors?
✅ Correct Answer: 3
38 Which of the following statement is correct whenever an object goes out of scope?
✅ Correct Answer: 3
Back to All Quizzes