Classes and Objects Quiz #2
Classes and Objects Quiz #2
CSC-162
Classes and Objects Quiz #2
a
x = 6.2
y = 1.9
b
x = 2.8
y = 5.6
c
x = 4.9
y = 6.4
A reference of a is passed into change as parameter u. In the first line of change, setting the
value of u to a new PlanePoint object will fully change the reference to which u points to.
Therefore, when change(a, b, c) is run, a remains unchanged since u no longer points to the
same object as a
u
x = 3.2
y = 74
a
x = 6.2
y = 1.9
v.setX(8.4)
b
x = 8.4
y = 5.6
w = u;
w will now point to the same object as u, which is the newly created object. Similar to what
happens to a, this will completely change the object that w points to. w no longer is pointing to c,
since its reference is changed to object u. Therefore, c will remain unchanged
u, w
x = 3.2
y = 74
c
x = 4.9
y = 6.4
A reference of b is passed into change as parameter u. In the first line of change, setting the
value of u to a new PlanePoint object will fully change the reference to which u points to.
Therefore, when change(a, b, c) is run, b remains unchanged since u no longer points to the
same object as b and therefore the code does not cause any changes to b
u
x = 3.2
y = 74
b
x = 8.4
y = 5.6
v.setX(8.4)
c
x = 8.4
y = 6.4
w = u;
w will now point to the same object as u, which is the newly created object. Similar to what
happens to a, this will completely change the object that w points to. w no longer is pointing to c,
since its reference is changed to object u. Therefore, a will remain unchanged
u, w
x = 3.2
y = 74
a
x = 6.2
y = 1.9
FINAL OUTPUT: