Difficulty: Easy
Correct Answer: The program will print the output 120.
Explanation:
Introduction / Context:
This question reinforces qualified calls to resolve ambiguity in multiply-inherited interfaces and shows how arguments flow into a function with defaults overridden at the call-site. The output is a straightforward arithmetic sum of three values stored in globals.
Given Data / Assumptions:
objDev.BaseTwo::Display(10, 20, 'Z')
.BaseTwo::Display
, the globals are set and gSum
is computed as the sum of the three converted values.'Z'
has integer code 90.
Concept / Approach:
The computation uses gDouble = 10
, gFloat = 20.0f
, gChar = 90
, so the sum is 10 + 20 + 90
. The function itself streams that sum via cout
, so the visible output is the numeric result.
Step-by-Step Solution:
Verification / Alternative check:
Calling BaseOne::Display(10.0, 20.0f, 'Z')
would compute the same numeric sum since the same values are used after conversions.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting to qualify the call in multiple inheritance, which would make the call ambiguous and fail to compile.
Final Answer:
The program will print the output 120.
Discussion & Comments