logo Practice-It logo

parameter mystery

Author: Roy McElmurry (on 2010/12/28)

What output is produced by the following program?

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);
    }
}
carbonated(coke, soda, pop);
carbonated(pop, pepsi, pepsi);
carbonated("pop", pop, "koolaid");
carbonated(say, "say", pop);

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.