• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

deserialization constructor execution doubt.

 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K&B page# 469
But these things do NOT happened when as object is deserialized, When an instance of a serializable class is deserializedthe constructor does not run...


They why following code giving output at the time of deserialization??


output is:
animal
dog
animal <= why its executing Animal class constructor at the time of desrialization???
 
Neha Daga
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because Animal class doesnot implements serializable interface and it is rule that when an object is deserialized all the super classes that do not implement serializable interface will have there constructor run.
 
Minhaj Mehmood
Ranch Hand
Posts: 400
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neha Daga wrote:because Animal class doesnot implements serializable interface and it is rule that when an object is deserialized all the super classes that do not implement serializable interface will have there constructor run.


thanks neha, then i might miss those lines from K&B.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
serialization not on exam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic