C++ Programming :: Constructors and Destructors

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

1 / 32

 Dynamic-destruction is

Adestruction of created objects. ,

Bdeallocation of memory when the object goes out of scope.

Csimply memory deallocation.

Drun-time memory deallocation.

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

2 / 32

 Which of the following statements are true?
(I). Constructors can be vitrual.
(II). Constructors can be vitrual. Codes:

ABoth are true.

BBoth are false

CI is true and II is false

DII is true and I is false

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

3 / 32

 Constructor is executed when _____.

Aan object is created

Ban object is used

Ca class is declared

Dan object goes out of scope.

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

4 / 32

 Which of the following gets called when an object is being created?

Aconstructor

Bvirtual function

Cdestructor

Dmain

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

5 / 32

 To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .

Adestructor

Bdelete

Cdelete[]

Dkill[]

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

6 / 32

 Which of the following statements is correct about the constructors and destructors?

ADestructors can take arguments but constructors cannot.

BConstructors can take arguments but destructors cannot.

CDestructors can be overloaded but constructors cannot be overloaded.

DConstructors and destructors can both return a value.

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

7 / 32

 Which of the following statement is correct?

AA constructor has the same name as the class in which it is present.

BA constructor has a different name than the class in which it is present.

CA constructor always returns an integer.

DA constructor cannot be overloaded.

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

8 / 32

 Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?

APreprocessor

BLinker

CLoader

DCompiler

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

9 / 32

 Which is called on allocating the memory for array of objects?

Adestructor

Bconstructor

Cmethod

DNone of the mentioned

Answer: Option B

Explanation:

When you allocate memory for an array of objects, the default constructor must be called to construct each object. If no default constructor exists, you are stuck needing a list of pointers to objects.

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

10 / 32

 Which of the following statement is correct about constructors?

AA constructor has a return type.

BA constructor cannot contain a function call.

CA constructor has no return type.

DA constructor has a void return type.

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace