Questions: What is the output of this Java program?
```
class Driver
public static void main(String[] args)
int a = foo(6);
int b = bar(a);
static int foo(int a)
a = bar(a - 3);
System.out.print(a);
return a;
static int bar(int a)
a = a - 1;
System.out.print(a);
return a + 2;
```
Transcript text: What is the output of this Java program?
```
class Driver {
public static void main(String[] args) {
int a = foo(6);
int b = bar(a);
}
static int foo(int a) {
a = bar(a - 3);
System.out.print(a);
return a;
}
static int bar(int a) {
a = a - 1;
System.out.print(a);
return a + 2;
}
}
```
Solution
Solution Steps
Step 1: Call foo(6)
The main method calls foo(6).
foo method receives a = 6.
Step 2: Inside foo, call bar(3)
Inside foo, a is updated by calling bar(a - 3), which is bar(3).