logo CodeStepByStep logo

ParameterMysteryExam2

Language/Type: Java parameters return

The following console program uses parameters and produces five lines of output. What are they?

public class ParameterMysteryExam2 {
    public static void main(String[] args) {
        String x = "happy";
        String y = "pumpkin";
        String z = "orange";
        String pumpkin = "sleepy";
        String orange = "vampire";

        orange(y, x, z);
        x = orange(x, z, y);
        orange(pumpkin, z, "y");
        z = "green";
        orange("x", "pumpkin", z);
        orange(x, z, orange);
    }

    public static String orange(String z, String y, String x) {
        System.out.println(y + " and " + z + " were " + x);
        return x + y + z;
    }
}
line 1
line 2
line 3
line 4
line 5

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.