Siu KWAN YuenPro Student 2,898 Points
How does the reference of an original instance different from that of its up/down casted instance?
Treet treet = new Treet("Sean", "Hello", new Date()) Object obj = treet; Treet another = (Treet) obj;
In the above code, We have an obj of class Object; however, the member variables of obj are all included in the instance, treet, and so, there is nothing new.
Does our computer store obj in a new memory? or do they (obj and treet) are referencing the same thing?
Btw, I have an assumption that needs to be confirmed. When you coercion the type of an instance, the converted instance only keeps the member variables of the new blueprint, meaning that when you upcast, it keeps all member variables of its super class, and when you downcast, it keeps all original member variables and set all new variables to the default value. is that true?