Parameter Mystery
Category: Parameter Mystery
Author: Marty Stepp and Ruth Anderson
Book Chapter: 3.1
Problem: Parameter Mystery
At the bottom of the page, write the output produced by the following program, as it would appear on the console.
public class ParameterMystery {
public static void main(String[] args) {
String pizza = "snow";
String apple = "skiers";
String x = "pizza";
String y = "smoothies";
String z = "apple";
smoothies("apple", z, y);
smoothies(z, x, z);
smoothies(apple, y, x);
smoothies(y, "smoothies", pizza);
String w = z + "-" + x;
smoothies("pizza", w, x);
}
public static void smoothies(String y, String z, String x) {
System.out.println(y + " like " + z + " and " + x);
x = x + "!";
}
}
1) smoothies("apple", z, y);
2) smoothies(z, x, z);
3) smoothies(apple, y, x);
4) smoothies(y, "smoothies", pizza);
5) smoothies("pizza", w, x);