Question: Suppose we have an Acct class in Java, which has an instance variable balance and also an instance method add (float amt), which adds the

Suppose we have an Acct class in Java, which has an instance variable balance and also an instance method add (float amt), which adds the argument amt to balance. We have also the following deposit() method. void deposit (float amt, Acct ac) {ac.add (amt);} (i) Recall that the Java language supports only pass-by-value parameter passing, which is an in-mode mechanism. Consider the following Java code fragment. Assuming that myAC.balance is 100 before the call to deposit (), what is the value of myAC.balance after executing the following code fragment? Acct myAC = new Acct; ... deposit (37.5, myAC); Give detailed steps to explain how you obtain your answer, perhaps with the aid of memory diagrams. ii) Object variables in Java sometimes behave like pointer variables and sometimes like reference variables. Explain the behavior (as pointer or reference) of myAC in parameter passing stage of the method call, and also the behavior of ac in the body of deposit ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
