| preferred AP College board partner for AP classes
AP Computer Science A/Unit 7: ArrayList
Start Practice TestPractice Test
About Exam
easy Solved by 14 students
Array Element Shifting With A For Loop
< Prev
Next >

Consider the following code segment.

int[] arr = {1, 2, 3, 4, 5, 6, 7};

for (int k = 3; k < arr.length - 1; k++) {
    arr[k] = arr[k + 1];
}

Which of the following represents the contents of arr after the code segment has been executed?

A

{1, 2, 3, 5, 6, 7, 8}

B

{1, 2, 3, 5, 6, 7, 7}

C

{1, 2, 3, 4, 5, 6, 7}

D

{2, 3, 4, 5, 6, 7, 7}

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
#1vempaami00011 0m 00s 100
#2kaisuki12 0m 00s 90
#3zgj0731041711 0m 41s 59
#4singh.advik1312 1m 02s 28
#5singhris00011 1m 40s 0
#6gizemsever68+tester01 0m 00s -10
#7psak1211 3m 46s -126
#8bommasam00003 1m 46s -136
#9y.seong202712 5m 25s -235
#10geethasailaja12 18m 36s -1,026
Items per page:
10
1 – 10 of 10
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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