Question: Suppose you have an updateAccount method with two parameters, an int variable named yearsAccumulatingInterest and a reference variable named bankAccount. The bankAccount variables object contains
Suppose you have an updateAccount method with two parameters, an int variable named yearsAccumulatingInterest and a reference variable named bankAccount. The bankAccount variable’s object contains an instance variable named balance. Within the method’s body, the yearsAccumulatingInterest parameter gets updated and the bankAccount object’s balance gets updated. In a method that calls the updateAccount method, after returning from the updateAccount method, the yearsAccumulatingInterest argument’s value is unchanged and the bankAccount argument’s balance value is changed. Explain why there is a difference.
Step by Step Solution
3.36 Rating (165 Votes )
There are 3 Steps involved in it
This difference is due to how parameters work in Java Java uses something called passbyvalue for all ... View full answer
Get step-by-step solutions from verified subject matter experts
