QuestionQ96

Creating and Using Arrays

Given this code fragment:

Question Image

What is the result?

  • A
Explanation

A multidimensional Java array is an array whose components can reference subarrays, and an array’s length is not part of its type. Therefore, the two int[] assignments of lengths 4 and 2 are valid. The enhanced for loops print the elements of the first assigned array as 1 3 5 7 and those of the second as 1 3, each on its own line.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!