Difficulty: Easy
Correct Answer: false true
Explanation:
Introduction / Context:This question confirms that Java passes primitives by value, so reassigning a parameter inside a method does not change the caller's variable.
Given Data / Assumptions:
Concept / Approach:Primitives are copied when passed to methods. Changing the local copy does not affect the original variable. The return value may differ from the original.
Step-by-Step Solution:
Before call: b1 is false.In fix: local b1 becomes true; method returns true.Back in start: original b1 remains false; b2 receives true.Prints "false true".Verification / Alternative check:Print identity or use different names to emphasize the copy behavior.
Why Other Options Are Wrong:They imply call-by-reference semantics, which Java does not use for primitives.
Common Pitfalls:Assuming Java can pass primitives by reference; only object references are passed by value (and still by value).
Final Answer:false true
Discussion & Comments