Given the following method public static int messAroundint a
Solution
Java Program:
In the method Call:
Initially,
Array a contains : [3, 6, 2, -1, 7];
m = 7; n = 3
--------------------------------------------------------------
1. Statement: m = a[1] + n;
m = 6 + 3 {a[1] = 3, n = 3}
m = 9
---------------------------------------------------------------
2. Statement: a[3] += 4;
a[3] = a[3] + 4; {a[3] = -1}
a[3] = -1 + 4
a[3] = 3;
---------------------------------------------------------------
3. Statement: a[4] += 3;
a[4] = a[4] + 3; {a[4] = 7}
a[4] = 7 + 3
a[4] = 10;
---------------------------------------------------------------
4. Statement: n = a[4];
n = 10 {a[4] = 10}
--------------------------------------------------------------
5. System.out.println(n + \" \" + m);
Prints 10 9 to console {n = 10 from step 4, m = 9 from step 1}
--------------------------------------------------------------
Function returns value 3 to calling function.
Hence Output to a screen with call b = messAround(data, 7, 3); is 10 9
Correct option is (b) 10 9
![Given the following method: public static int messAround(int[] a, int m, int n) {m = a[1] + n; a[3] + = 4; a[4] += 3; n = a[4]; System.out.println(n + \ Given the following method: public static int messAround(int[] a, int m, int n) {m = a[1] + n; a[3] + = 4; a[4] += 3; n = a[4]; System.out.println(n + \](/WebImages/39/given-the-following-method-public-static-int-messaroundint-a-1117615-1761594005-0.webp)