Originally posted by Chandra Bhatt:
Thanks Paul,
It means even if Dog extends Animal (Dos IS-A Animal) and Animal implements
Serializable. While serializing the Dog, only Dog is serialized. Dog is full fledged Animal as well so all animal things accessible to Dog will also be serialized but because they are part of Dog object, (only Dog object will be serialized)
Thanks,
cmbhatt
I suspected that you were getting confused between classes and objects but I wasn't sure.
Dog and Animal are two classes but when you create a Dog object, there is only one object, which is the Dog object you created. Since a Dog is-a Animal, a Dog object includes everything that is required to be an Animal (and Object, since Object is the root class of all classes). There aren't two (or three, if you count Object class as well) objects. There is only one Dog object but it contains all the Animal (and Object) stuff as well.
It's like when you buy a Car, do you get just one thing Car or do you get two things a Car and an Automoble?