Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Data Collections
Start Practice TestPractice Test
About Exam
medium Solved by 1 students

Array Left Shift Algorithm

Mark
< Prev
Next >

Consider the following code segment.

int[] values = {10, 20, 30, 40, 50};
int temp = values[0];
for (int i = 0; i < values.length - 1; i++) {
    values[i] = values[i + 1];
}
values[values.length - 1] = temp;

for (int i = 0; i < values.length; i++) {
    System.out.print(values[i] + " ");
}

What is printed when this code segment is executed?

A

50 10 20 30 40

B

10 20 30 40 50

C

40 50 10 20 30

D

20 30 40 50 10

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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