logo Practice-It logo

BJP5 Self-Check 3.14: parameterMysteryReturn

Author: Leslie Ferguson (on 2019/09/19)

Given the following program:

public class MysteryReturn {
    public static void main(String[] args) {
        int x = 1;
        int y = 2;
        int z = 3;
        
        z = mystery(x, z, y);                        // Statement 1
        System.out.println(x + " " + y + " " + z);   // Statement 2
        x = mystery(z, z, x);                        // Statement 3
        System.out.println(x + " " + y + " " + z);   // Statement 4
        y = mystery(y, y, z);                        // Statement 5
        System.out.println(x + " " + y + " " + z);   // Statement 6
    }

    public static int mystery(int z, int x, int y) {
        z--;
        x = 2 * y + z;
        y = x - 1;
        System.out.println(y + " " + z);
        return x;
    }
}

Write the output of each statement.

Statement 1
Statement 2
Statement 3
Statement 4
Statement 5
Statement 6

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.