This is a beta version of Practice-It. Give us feedback

logo Practice-It logo

parameterMysteryPicnic

Author: Stuart Reges (on 2020/10/06)

Consider the following program.

public class Mystery {
    public static void main(String[] args) {
        String x = "lemonade";
        String y = "ants";
        String z = "picnic";
        String picnic = "y";
        String ants = x + picnic;

        picnic(x, y, z);
        picnic(y, picnic, "ants");
        picnic(y + z, y + picnic, ants);
        picnic = "sunny";
        picnic(picnic, "today", x);
    }

    public static void picnic(String z, String y, String x) {
        System.out.println(x + " and " + z + " like " + y);
    }
}

List below the output produced by this program.

picnic(x, y, z);
picnic(y, picnic, "ants");
picnic(y + z, y + picnic, ants);
picnic(picnic, "today", x);

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.