Module: | Classes, Objects, OOPs & Inheritance
Q35: Consider the following statements regarding multidimensional and jagged arrays in Java:
1. Multidimensional arrays in Java are technically implemented as arrays of arrays, naturally allowing developers to create highly irregular structures known as jagged arrays.
2. When declaring a two-dimensional jagged array using the 'new' keyword, it is architecturally mandatory to specify the exact size of the outermost (row) dimension during the initial instantiation.
3. Java structurally forces all inner sub-arrays within a jagged array to reside in perfectly contiguous memory blocks to heavily optimize CPU cache locality for intensive scientific computing.
Which of the above statements is/are correct?
2. When declaring a two-dimensional jagged array using the 'new' keyword, it is architecturally mandatory to specify the exact size of the outermost (row) dimension during the initial instantiation.
3. Java structurally forces all inner sub-arrays within a jagged array to reside in perfectly contiguous memory blocks to heavily optimize CPU cache locality for intensive scientific computing.
Which of the above statements is/are correct?
✅ Correct Answer: A
🎯 Quick Answer:
The correct combination is 1 and 2. Statement 3 is incorrect because Java treats each inner array as an entirely separate object dynamically allocated in the Heap, meaning they are widely scattered and rarely contiguous in physical memory.Structural Breakdown: Instantiating a jagged array requires syntax like 'int[