Limited access

Upgrade to access all content for this subject

Consider the following methods.

public class testClass
{
    public static String sSearch(int[] x, int key)
    {
        String y = "";
        boolean z = false;
        for (int i = 0; i < x.length; i++)
        {
            if (x[i] == key)
            {
                y += i + " ";
                z = true;
            }
        }
        if (!z)
            y = "key was not found";

        return y;
    }

    public static void testMethod()
    {
        int[] y = new int[12];
        for (int i = 0; i < y.length; i++)
            y[i] = 5*(i/4);

        System.out.println(sSearch(y, 5));
    }
}

Which of the following is printed to console when testMethod() is called?

A
4 5 6
B
4 5 6 7
C
4 6 7 8 9 10 11 12 13 14
D
5 6 7 8 9 10 11 12 13 14
E

key was not found

Select an assignment template