Limited access

Upgrade to access all content for this subject

Before the loop begins, status is an array list of Strings which contains ["freshman", "sophomore", "junior", "senior", "graduate"].

int i=status.size()-1;
while(i>=0)
{
    String temp = status.get(i);
    status.set(Math.abs(i-status.size()+1), status.get(i));
    status.set(i, temp);
    i--;
}

What is the result after this segment of code is executed?

A

This is an example of an infinite loop.

B

status contains: ["graduate", "senior", "junior", "senior", "graduate"]

C

status contains: ["graduate", "senior", "junior", "sophomore", "freshman"]

D

status contains: ["freshman", "sophomore", "junior", "senior", "graduate"]

E

status contains: ["freshman", "sophomore", "junior", "sophomore", "freshman"]

Select an assignment template