Originally posted by John Stone:
>> "Member variables are not called polymorphically."
True, but I don't see any connection to situation Obaid described.
I said that in connection to the comment/uncomment Line #1 (marked bold).
I thought If Obaid would be under impression of such an case I described
above. His case is genuine, what the rule of Serialization says, if the
parent class is not Serializable, while deserializing child class object,
the constructor of the Parent class is called.
If Monkey class had its own name variable, as well as overridden toString()
method, the "Monkey" would be printed; otherwise, while deserailizing
Monkey, constructor of the Animal is called and we get name ="animal",
irrespective even if we have name in the Monkey class as well.
Thanks,