In what order are automatic objects of the same block destroyed?
-
A
Reverse of their construction order
Correct answer
-
B
Same as their construction order
-
C
In alphabetical order of names
-
D
In an order chosen by the linker
Correct answer
A. Reverse of their construction order
18 views
Explanation
Objects are destroyed in the reverse order of construction, exactly like a stack unwinding.
Reference
Asked in: NTS, PPSC IT, Campus Interviews
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ