Difficulty: Easy
Correct Answer: The program will print the output CuriousTab.
Explanation:
Introduction / Context: This question checks understanding of automatic storage duration and the order of constructor/destructor calls in C++. Output is produced first by the constructor and then by the destructor when the object goes out of scope at the end of main.
Given Data / Assumptions:
Concept / Approach: For an automatic object, construction occurs upon entering the block and destruction occurs on leaving it. Thus, the concatenated stream shows constructor text followed by destructor text without a newline: "CuriousTab".
Step-by-Step Solution:
Enter main → construct objTab → prints "Curious".Exit main → destroy objTab → prints "Tab".Final combined output: CuriousTab.Verification / Alternative check: Allocating with new would print only the constructor text unless delete is called; here, automatic storage ensures destructor runs.
Why Other Options Are Wrong:
Common Pitfalls: Expecting a newline or space between outputs; misunderstanding when destructors execute for automatic variables.
Final Answer: The program will print the output CuriousTab.
Discussion & Comments