Difficulty: Medium
Correct Answer: 10 34.34
Explanation:
Introduction / Context:
This program tests overload resolution (int to double conversion) and how doubles are formatted when concatenated with a string in Console.WriteLine.
Given Data / Assumptions:
Concept / Approach:
An int is implicitly converted to double to match the fun(double) signature. In the expression d + " ", the double is converted to its default string representation (culture-dependent general format “G”), then concatenated with a single trailing space, and finally written with a newline by WriteLine.
Step-by-Step Solution:
Verification / Alternative check:
Replacing WriteLine(d + " ") with WriteLine("{0} ", d) yields the same text. Using ToString("F6") would produce six fixed decimals (not used here).
Why Other Options Are Wrong:
Common Pitfalls:
Expecting WriteLine to preserve trailing zeros without an explicit format string; confusing numeric formatting with basic concatenation behavior.
Final Answer:
10 34.34
Discussion & Comments