| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice Test
Share
medium Solved by 2 students
Jagged 2D Array Traversal
< Prev
Next >

What is printed as a result of executing the following code segment?

public class JaggedPrint {
    public static void main(String[] args) {
        int[][] jagged = { {1,2,3}, {4,5}, {6,7,8,9} };
        for (int i = 0; i < jagged.length; i++) {
            for (int j = 0; j < (i+2); j++) {
                if(j < jagged[i].length)
                    System.out.print(jagged[i][j] + " ");
            }
        }
    }
}
A

1 2 4 5 6 7 8

B

1 2 3 5 6 7 8 9

C

1 2 3 4 5 6 7 8

D

1 2 4 5 6 7 8 9

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1upadhgau00001 0m 00s -10
#2imeanbusinessreplit01 0m 00s -10
#3y.seong202712 3m 46s -136
#4bommasam00014 5m 57s -287
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy