Difficulty: Easy
Correct Answer: 4
Explanation:
Introduction / Context:This question tests default argument handling in a base constructor and how pre/post operators affect state across member functions, including an override of Display() in the derived class.
Given Data / Assumptions:
Concept / Approach:Trace the member y across operations in order: initialization, increment, and pre-decrement during display. The code never uses the base Display(); it uses the override in the derived type, operating on the same y member inherited from the base.
Step-by-Step Solution:
1) After construction: y = 4.2) Call Increment(): y becomes 5.3) Call Display(): pre-decrement prints 4 and sets y = 4.Verification / Alternative check:If you instead called the base Display() (e.g., objCuriousTab.CuriousTabBase::Display()), the same calculation would occur since both versions print --y.
Why Other Options Are Wrong:
Common Pitfalls:Forgetting that ++ and -- change the stored value, not just the printed value.
Final Answer:4
Discussion & Comments