Parameter Mystery
Category: Parameter Mystery
Author: Victoria Kirst
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 soda = "coke";
String pop = "pepsi";
String coke = "pop";
String pepsi = "soda";
String say = pop;
carbonated(coke, soda, pop);
carbonated(pop, pepsi, pepsi);
carbonated("pop", pop, "koolaid");
carbonated(say, "say", pop);
}
public static void carbonated(String coke, String soda, String pop) {
System.out.println("say " + soda + " not " + pop + " or " + coke);
}
}
1) carbonated(coke, soda, pop);
2) carbonated(pop, pepsi, pepsi);
3) carbonated("pop", pop, "koolaid");
4) carbonated(say, "say", pop);