‹ Back to the paper
Assume `int [ ] [ ] x = { {8,9} , {5,6,7},{1,2,3,4}}`, what are `x[0].length`, `x[1].length`, and…
Assume `int [ ] [ ] x = { {8,9} , {5,6,7},{1,2,3,4}}`, what are `x[0].length`, `x[1].length`, and `x[2].length`?
- a2, 3 and 3
- b2, 3 and 4
- c3, 3 and 3
- d2, 2 and 2
Answer
Answer
AICorrect option: b
Answer: (b) 2, 3 and 4.
x[0] = {8,9} has length 2, x[1] = {5,6,7} has length 3, and x[2] = {1,2,3,4} has length 4 - each row of this jagged array can have its own length.
From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 6.