logo Practice-It logo

arrayMystery3

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

Consider the following method:

public static void mystery3(int[] nums) {
    for (int i = 0; i < nums.length - 1; i++) {
        if (nums[i] > nums[i + 1]) {
            nums[i + 1]++;
        }
    }
}

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.

{42}
{14, 7}
{7, 1, 3, 2, 0, 4}
{10, 8, 9, 5, 5}
{12, 11, 10, 10, 8, 7}

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.