Difficulty: Easy
Correct Answer: Widening conversions take place automatically.
Explanation:
Introduction / Context:
Understanding numeric and object conversions in .NET avoids runtime errors and precision loss. This question distinguishes widening vs. narrowing conversions, boxing/unboxing, and literal suffixes.
Given Data / Assumptions:
Concept / Approach:
Widening conversions are implicit (e.g., int to long, float to double) because they cannot overflow by definition within the type system's range rules. Narrowing conversions (e.g., double to float, long to int) are explicit and can lose information. Boxing is converting a value type to object; unboxing is the reverse. For decimal literals, the correct suffix is M (or m), not F.
Step-by-Step Solution:
Verification / Alternative check:
Compile small samples: implicit int→long works; long→int requires a cast. Literal 3.14M compiles to Decimal; 3.14F is Single.
Why Other Options Are Wrong:
They either invert definitions (boxing vs. unboxing), rely on the wrong language helper, or misuse literal suffixes.
Common Pitfalls:
Assuming all numeric conversions are safe; forgetting that only M/m marks a Decimal literal.
Final Answer:
Widening conversions take place automatically.
Discussion & Comments