Difficulty: Easy
Correct Answer: The default value of numeric array elements is zero.
Explanation:
Introduction / Context:
This conceptual MCQ checks basic facts about C# arrays: allowed element types, the meaning of rank and length, default initialization of elements, and whether arrays are automatically sorted by the runtime.
Given Data / Assumptions:
Concept / Approach:
Arrays are reference types whose elements are initialized to default values (0 for numeric types, false for bool, null for reference types). Rank is the number of dimensions (e.g., 1 for int[], 2 for int[ , ]). Length is the total number of elements across all dimensions. No automatic sorting occurs upon creation or assignment.
Step-by-Step Solution:
Verification / Alternative check:
Create int[3] a = new int[3]; printing values shows 0 0 0; a.Rank returns 1; a.Length returns 3.
Why Other Options Are Wrong:
They contradict the CLR definitions of rank, length, and default initialization, or claim an unsupported guarantee (sorting).
Common Pitfalls:
Confusing rank with length, and assuming arrays of value types are uninitialized (they are zero-initialized by the runtime).
Final Answer:
The default value of numeric array elements is zero.
Discussion & Comments