Difficulty: Easy
Correct Answer: The program will print the output 2.
Explanation:
Introduction / Context:
This problem mixes enum-to-int initialization, reference aliasing, and post-decrement printing behavior. All references y and z alias the same underlying int x.
Given Data / Assumptions:
Concept / Approach:
With aliasing, assignments via any reference affect x. The expression z-- is post-decrement, so it prints the old value of x (which is 2) and only then decrements x to 1.
Step-by-Step Solution:
Verification / Alternative check:
Replacing z-- with --z would print 1 immediately because pre-decrement decrements before yielding the value.
Why Other Options Are Wrong:
1 or 3 would require different timing of decrement or no prior assignment; compile error does not apply.
Common Pitfalls:
Forgetting that all references alias the same int and misapplying pre/post decrement semantics.
Final Answer:
The program will print the output 2.
Discussion & Comments