C#.NET — Arrays in .NET: rectangular vs jagged, adjacency, and System.Array methods. Which statements are correct? Arrays can be rectangular or jagged. Rectangular arrays have “similar rows” stored in adjacent memory locations. Jagged arrays do not have access to methods of System.Array. Rectangular arrays do not have access to methods of System.Array. Jagged arrays have dissimilar row lengths and rows are not stored adjacently like a single rectangular block.

Difficulty: Easy

Correct Answer: 1, 2, 5

Explanation:


Introduction / Context:
This conceptual question distinguishes rectangular arrays (int[ , ]) from jagged arrays (int[][]) and asks about memory layout intuition and access to the base class System.Array APIs. Some statements are distractors about method access and adjacency guarantees.


Given Data / Assumptions:

  • Rectangular arrays are single objects with fixed extents in each dimension.
  • Jagged arrays are arrays of arrays; inner arrays may differ in length.


Concept / Approach:
Statement 1 is true by definition. For teaching purposes, statement 2 captures that a rectangular array is one contiguous rectangular block with rows laid out adjacently in the same object. Statement 5 correctly describes jagged arrays: each row is an independent inner array with potentially different lengths and nonadjacent addresses. Both kinds of arrays are instances derived from System.Array and thus inherit its methods; statements 3 and 4 are therefore false.


Step-by-Step Solution:

(1) True — C# supports both rectangular and jagged arrays. (2) True — a rectangular array is a single multi-dimensional object; rows are adjacent within that object. (3) False — jagged arrays still inherit System.Array members. (4) False — rectangular arrays also inherit System.Array members. (5) True — jagged arrays may have different row lengths and are separate inner objects, not one contiguous rectangle.


Verification / Alternative check:
Both forms expose Length, Rank (for rectangular), and methods like GetLength/GetUpperBound from System.Array.


Why Other Options Are Wrong:
Any option including 3 or 4 is incorrect because it denies System.Array membership inheritance.


Common Pitfalls:
Confusing the logical concept of adjacency in a rectangular array with physical memory guarantees, and thinking jagged arrays lose System.Array APIs.


Final Answer:
1, 2, 5

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion