| preferred AP College board partner for AP classes
AP Computer Science A/Unit 8: 2D Array
Start Practice TestPractice Test
About Exam
medium Solved by 14 students
Summing Elements in a 2D Array
< Prev
Next >

Consider the following code segment.

int[][] arr = {{1, 2, 3, 4},
               {5, 6, 7, 8},
               {9, 10, 11, 12}};

int sum = 0;
for (int[] x : arr)
{
    for (int y = 0; y < x.length - 1; y++)
    {
        sum += x[y];
    }
}

What is the value of sum after the code segment has been executed?

A

78

B

36

C

54

D

68

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki12 0m 00s 90
#2midnightasdark11 0m 22s 78
#3dobaonam838612 0m 48s 42
#4mullameh00112 1m 16s 14
#5geethasailaja01 0m 54s -64
#6ajcantuwilson032512 3m 47s -137
#7varunrajaram101 2m 22s -152
#8y.seong202702 3m 20s -220
#9ponneban00011 15m 07s -807
#10psak1211 15m 45s -845
Items per page:
10
1 – 10 of 11
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy