Since d is an attribute that every dog object has, i think that d1.d=d2 would imply that you are trying to make the d1's (member) d to refer to the same dog object that d2 refers to. This should run perfectly well though I think the code is poorly crafted in terms of design.
You should generally use get/set methods to change the attributes of objects to prevent client code from indiscriminately altering them.
By the way,where did you get such cryptic looking code from?was it an exam question?I'm also preparing for scjp5.0