Note: If some answer does not make sense, or it's not well explained I apologise, please leave a question in the gist.
-
Q2a: Answer -> 4
- The field was initialised at first with
2, after thata.work()was called which changed the current value ofa.xto the return value of callingcomputeon the result ofgetXwhich simply will returnb.x, compute is defined for B asv -> v * 2, which madexequal to2.
- The field was initialised at first with
-
Q2b: Answer -> 5