5. What is the value of &x ?
Answer: &x = 4
Variables are passed into local functions by reference.
&x exists in and outside the local function and &n is just a
pointer to &x. &x is therefore momentarily set to 2.
7. What is the value of &x ?
Answer: &x = 2
Variables are passed into external functions by reference.
Local function variable &x only exist in the external function.
9. What are the values
of &f.value and &g.value ?
Answer: &f.value = “g” &g.value = “g”
Objects are assigned by reference.
Both &g and &f point to the same string variable.
11. What is the value of &a and &b ?
Answer: &a = “a” &b = “b”
Primitives are assigned by value.
Both &a and &b are discreet variables.
&b is set the value of &a and does not point to &a.
13. What is the
value of &p ?
Answer: &p = 1
Methods pass primitives by value.
14. What is the
value of &r ?
Answer: &r = “xyz”
Methods pass objects by reference
15. Written by Graham Smith
http://i-like-trains.blogspot.co.uk/
I found this helpful – I hope you did too.
Please feel free to comment, correct, add to
and share freely.