Originally posted by Swapnil Trivedi:
Q class Animal implements Serializable { Dog d; }
class Dog { }
When we attempt to serialize an instance of Animal class then what is the result:
a)One object is serialized
b)An exception is thrown at runtime.
Ans: one object is serialized..
My Doubt is what will be the bahaviour of Dog instance while serialization...
--->Since its not instantiated so the compiler will not throw any exception(or will it throw the "NotSerializable Exception"???)
--->Its not transient.If it would have marked transient then compiler would skip it...
So now in the given case when the Animal instance will be deserialized what would compiler will do with that instance???
Thanks!!!
Swapnil
I think, it should throw an exception...