In the below diagram, I have a query on name temp
that is returned from function f
In local frame f
, temp
is a reference variable pointing to an object 6
of class int
, when you say return temp
in f
a reference variable output
which is part of checkPassingMech
frame will point to the same object 6
that temp was pointing to.
My question:
Q1) Is my understanding correct?
Q2) If Q1 is yes, then this diagram is giving an illusion that temp
is not reference type and showing its value in a box rather than with an arrow pointing to 6, am i correct?
Q3) If Q2 is yes, then, Can i say that 6
is actually stored in heap and temp
and output
would be pointing to this heap space from frame(local stack)