Reference Type and Object Type Changing Java
The type of the object reference is defined statically at the point of its declaration:
Z myZ = ...
Therefore, the type of the reference is Z
, so "C" should be the right answer.
The Object was created with new Y();
so the object type is Y
myZ
was declared as Z
(Z myZ = ...;
) so the reference type is Z
Hence, the right answer is C