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

1 Expert Approved Answer
Step: 1 Unlock

This difference is due to how parameters work in Java Java uses something called passbyvalue for all ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!