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

Which of the following represents the contents of arr as a result of executing the code segment?
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 as a result of executing the code segment?

A

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

B

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

C

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

D

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

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1vempaami00011 0m 00s 100
#2kaisuki12 0m 00s 90
#3singh.advik1312 1m 02s 28
#4singhris00011 1m 40s 0
#5gizemsever68+tester01 0m 00s -10
#6y.seong202712 5m 25s -235
#7geethasailaja12 18m 36s -1,026
APFIVE © 2020.
Email: [email protected]|Privacy Policy