Question: The following console program uses parameters and produces eight lines of output. What are they? public class ParameterMysterySection 2 { public static void main (

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To determine the output of this console program we will analyze the sequence of operations and under... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!