*
The moose likes Java in General and the fly likes Can't Understand How It Comes In Deserialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can Watch "Can New topic
Author

Can't Understand How It Comes In Deserialization

panadare aniruddha
Greenhorn

Joined: Feb 06, 2011
Posts: 3


The OutPut Is :->
Animal
Dog
Animal

How ?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

Can you UseCodeTags in future? It makes your posts much easier to read, so you're more likely to get a useful reply. I've added them this time.

The question is all about the order constructors get called, and which constructors get called when an object is deserialized. Do you know what the rules are for that? Basically:

- The initial creation of the Dog object prints Animal/Dog, because superclass constructors are called first.

- The constructor of a serializable object is not called when deserializing. But if the superclass is not serializable, its constructor will be called. Change the code to make Animal serializable and you'll notice a change in the output.

Does that help?
panadare aniruddha
Greenhorn

Joined: Feb 06, 2011
Posts: 3
Thank you Very much Matthew
 
jQuery in Action, 2nd edition
 
subject: Can't Understand How It Comes In Deserialization
 
Similar Threads
Serialization in java
Serialisation - K&B
Nice Serialization Question
Constructors called when deserializing properly serialized subclass instance
Serialization