logo Practice-It logo

parameter mystery

Author: Kimberly Todd (on 2010/12/28)

Given the following program:

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);
    }
}

Write the output of each of the following calls, as it would appear on the console.

troops(p, q, r);
troops(q, r, p);
troops(support, p, cause);
troops(r, "p", support);
troops(q, "cause", q);

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.