Difficulty: Medium
Correct Answer: 15 15
Explanation:
Introduction / Context:
This program demonstrates that arrays are objects in Java, and references to the same array point to the same underlying storage. Modifying the array via one reference is visible through all references to that array.
Given Data / Assumptions:
Concept / Approach:
Java passes references by value. The parameter a3 points to the same array object as a1 does. Therefore the in-place update a3[1] = 7 mutates a1 as well. Both a1 and a2 refer to the same modified array.
Step-by-Step Solution:
Verification / Alternative check:
Printing a1 == a2 yields true (same reference). Printing Arrays.toString(a1) after fix shows [3, 7, 5].
Why Other Options Are Wrong:
They either treat prints as element-by-element strings or assume the array did not mutate.
Common Pitfalls:
Confusing pass-by-value of the reference with copying the array; forgetting that arithmetic here is numeric addition, not concatenation.
Final Answer:
15 15
Discussion & Comments