logo CodeStepByStep logo

ParameterMysterySection2

Language/Type: Java parameters return

The following console program uses parameters and produces eight lines of output. What are they?

public class ParameterMysterySection2 {
    public static void main(String[] args) {
        int a = 137;
        int b = 42;

        System.out.println("a = " + a);
        foo(b);
        System.out.println("a = " + a);
        System.out.println("b = " + b);

        a = bar(b, a + b);  
        System.out.println("a = " + a);
        a = bar(a, b);  
        System.out.println("a = " + a);
    }

    public static void foo(int a) {
        System.out.println("a = " + a);
        a = 160;
    }

    public static int bar(int c, int b) {
        int d = b - c;
        System.out.println("d = " + d);
        return d % 10;
    }
}
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.