Difficulty: Easy
Correct Answer: 1, 3, 5
Explanation:
Introduction / Context:
Correctly distinguishing value types and reference types in C#.NET is foundational for understanding memory behavior, default values, and assignment semantics.
Given Data / Assumptions:
Concept / Approach:
Value types (structs, built-in numerics, bool, etc.) have an implicit parameterless constructor provided by the runtime that produces the type's default value (e.g., 0 for numerics, false for bool). All value types derive from System.ValueType. Reference-type variables store references to objects. Non-nullable value types cannot hold null; definite assignment requires locals be assigned before use.
Step-by-Step Solution:
Verification / Alternative check:
Inspect IL or use default keyword: int x = default; compiles and initializes x to 0.
Why Other Options Are Wrong:
They contradict definite assignment or nullability rules.
Common Pitfalls:
Assuming one may define custom parameterless constructors for structs (historically disallowed) or that locals auto-initialize like fields (they do not).
Final Answer:
1, 3, 5
Discussion & Comments