?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Array of Strings Furniture Counts

APCSA-8VPKNG

After the following code is executed, what is the value of count?

String[] furniture = {"chair", "table", "cabinet", "bed", "sofa"};
int count=0;

for (int i=1; i<furniture,length; i++)
{
    for (int k=0; k<furniture[i-1].length(); k++
    {
        if (furniture[i].indexOf(furniture[i-1].substring (k,k+1))>=0)
            count++;
    }
}
A

5

B

6

C

7

D

8

E

An "array index out of bounds" error is thrown before it completes execution