Limited access

Upgrade to access all content for this subject

Consider the following code.

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++;
    }
}

What is the value of count after the code is executed?

A

5

B

6

C

7

D

8

E

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

Select an assignment template