Programming - C++ Language
You Are Here :: Home > C++ Language > constructor - General Questions
7.
Only the address of the object is transferred to the function
A.
Pass-by-reference
B.
Pass-by-pointer
C.
Pass-by-value
D.
None of the above
Answer: Option A
Explanation:
8.
A constructor
A.
Constructs new data type
B.
Enables the initialization of an object as it is created
C.
Obtain memory for a new variable
D.
None of the above
Answer: Option B
Explanation:
9.
Which of the following is called automatically each time an object is created?
A.
Compiler
B.
Builder
C.
Constructor
D.
Destructor
Answer: Option C
Explanation:
10.
Which of the following is called automatically each time an object goes out of scope?
A.
Compiler
B.
Builder
C.
Constructor
D.
Destructor
Answer: Option D
Explanation:
11.
When writing a class, the compiler automatically creates some support functions for the class. What are some of these functions?
A.
Assignment operator function
B.
Copy constructor
C.
Assignment operator and copy constructor
D.
None of the Above
Answer: Option C
Explanation:
12.
Assume you have to write a class that makes use of dynamic memory allocation (the class needs to allocate and de-allocate memory). According to best practices, where would the keyword ‘new’ be placed?
A.
Classes are smart data types. The compiler takes care of calling new/delete.
B.
In the constructor
C.
In the destructor
D.
In a separate, dedicated function
Answer: Option B
Explanation:
« prev
next »