This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes deserialization constructor execution doubt. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "deserialization constructor execution doubt." Watch "deserialization constructor execution doubt." New topic
Author

deserialization constructor execution doubt.

Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

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???


SCJP6 96% | SCWCD5 81% | SCDJWS5 79%
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
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.


SCJP 1.6 96%
Minhaj Mehmood
Ranch Hand

Joined: Jan 22, 2007
Posts: 400

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

Joined: Dec 10, 2009
Posts: 521
serialization not on exam


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: deserialization constructor execution doubt.
 
Similar Threads
Regarding Serialization
Can't Understand How It Comes In Deserialization
Nice Serialization Question
Constructors called when deserializing properly serialized subclass instance
Serialization