Difficulty: Easy
Correct Answer: 1 and 3 only
Explanation:
Introduction / Context:This item probes understanding of jagged arrays (arrays of arrays) in C#. A jagged array 'int[][]' holds references to independent 1-D arrays. Rows can have different lengths and are separate objects on the heap, unlike a single rectangular block.
Given Data / Assumptions:
Concept / Approach:Jagged arrays are not guaranteed to place each inner array in adjacent memory locations. The outer 'int[][]' variable refers to the outer array object whose elements are references to inner arrays. Access semantics make intMyArr[0] and intMyArr[1] the first and second inner arrays respectively.
Step-by-Step Solution:
(1) True — 'int[][]' is a jagged array with two inner arrays. (2) False — inner arrays are separate objects; adjacency is not guaranteed. (3) True — intMyArr[0] is the 0th inner array, intMyArr[1] is the 1st inner array. (4) False — intMyArr refers to the outer array object, not directly to both inner arrays simultaneously. (5) False — index 2 does not exist; valid row indices are 0 and 1.Verification / Alternative check:Print lengths: Console.WriteLine(intMyArr[0].Length); // 4, Console.WriteLine(intMyArr[1].Length); // 3. This confirms separate inner arrays.
Why Other Options Are Wrong:Any option including (2), (4), or (5) is incorrect because those statements misrepresent jagged array memory layout or use an invalid index.
Common Pitfalls:Confusing jagged arrays with rectangular arrays int[ , ] and assuming a contiguous 2-D memory layout.
Final Answer:1 and 3 only
Discussion & Comments