?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

Synonym Deletion

APCSA-PFGJEV

Consider the following code.

ArrayList<String> syn = // list of synonyms

for (int i=0; i< syn.size(); i++)
{
    if (syn.get(i).length()>1 && syn.get(i).substring(1).indexOf(syn.get(i).substring(0,1))>=0)
    {
        syn.remove(i);
        break;
    }    
}

Which of the following BEST describes the purpose of this code?

A

It examines elements in syn. If the element contains no other occurrences of the element's first character, then the element is removed from syn and no other elements are checked.

B

It examines elements in syn. If the element contains no other occurrences of the element's first character, then the element is removed from syn. This process continues for all other elements in syn.

C

It examines elements in syn. If the element contains at least one other occurrence of the element's first character, then the element is removed from syn and no other elements are checked.

D

It examines elements in syn. If the element contains at least one other occurrence of the element's first character, then the element is removed from syn. This process continues for all other elements in syn.

E

It examines elements in syn. If the element contains at least one occurrence of the first character from the first element (at position 0) of syn, then the element is removed from syn and no other elements are checked.