When does a constructor run for an automatic object?
-
A
When the object is first read from
-
B
When the enclosing scope ends
-
C
Only when new is used to create it
-
D
When the object comes into existence
Correct answer
Correct answer
D. When the object comes into existence
17 views
Explanation
A constructor initialises the object automatically at the point where its definition is reached.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is D? Ask here and get an explanation.
Ask a doubt about this MCQ