logo Practice-It logo

arrayMystery2

Language/Type: Java arrays array mystery
Author: Marty Stepp

Consider the following method:

public static void mystery2(int[] list) {
    for (int i = 0; i < list.length - 1; i++) {
        if (i % 2 == 0) {
            list[i]++;
        } else {
            list[i]--;
        }
    }
}

For each array below, indicate what the array's contents would be after the method mystery were called and passed that array as its parameter.

{6, 3}
{2, 4, 6}
{1, 2, 3, 4}
{2, 2, 2, 2, 2}
{7, 3, 2, 0, 5, 1}

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.