C++ Programming - Constructors and Destructors

Exercise :: Constructors and Destructors - General Questions

31. 

A class's __________ is called when an object is destroyed.

A. constructor
B. destructor
C. assignment function
D. copy constructor

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

32. 

Destructors __________ for automatic objects if the program terminates with a call to function exit or function abort.

A. are called
B. are inherited
C. are not called
D. are created

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.

33. 

Which of the following statement is correct?

A. A constructor of a derived class can access any public and protected member of the base class.
B. Constructor cannot be inherited but the derived class can call them.
C. A constructor of a derived class cannot access any public and protected member of the base class.
D. Both A and B.

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

34. 

Which of the following statements are correct?

A. Constructor is always called explicitly.
B. Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
C. Destructor is always called explicitly.
D. Constructor and destructor functions are not called at all as they are always inline.

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

35. 

How many times a constructor is called in the life-time of an object?

A. Only once
B. Twice
C. Thrice
D. Depends on the way of creation of object

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.