Parameter Mystery
Category: Parameter Mystery
Author: Marty Stepp
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 p = "cause";
String q = "support";
String r = "troops";
String support = "hillary";
String cause = "rudy";
troops(p, q, r);
troops(q, r, p);
troops(support, p, cause);
troops(r, "p", support);
troops(q, "cause", q);
}
public static void troops(String r, String p, String q) {
System.out.println(q + " gave " + r + " to the " + p);
}
}
1) troops(p, q, r);
2) troops(q, r, p);
3) troops(support, p, cause);
4) troops(r, "p", support);
5) troops(q, "cause", q);