Forums Register Login

Related to Object Serialization

+Pie Number of slices to send: Send
Hi,

The following code prints "pcp" whereas i think it should print "pcpc". Can anybody explains why it prints "pcp"?

+Pie Number of slices to send: Send
How about you explaining why you think it prints that final "c"?
+Pie Number of slices to send: Send
Hi Ali,

i think it should print "pcpc"



First think about, what Barry said, but if you don't get it, see below the "spoiler".













spoiler

The last c will not print, because in deserialization, the constructors of classes implementing Serializable will not run.
Only constructors of superclasses not implementing Serializable will run.

If you have the K&B book, you can look it up on pages 453 and the following.



Yours,
Bu.
[ October 06, 2006: Message edited by: Burkhard Hassel ]
+Pie Number of slices to send: Send
I think that when it will read the object from serialized file, it will create new CardPlayer() and will then set the values, so if its true then again "pc" should be printed making "pcpc", but i know i am wrong

Can you explain why?
+Pie Number of slices to send: Send
Thanks BH, i got that
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 914 times.
Similar Threads
serialization question
Serialization doubt
Questions from K&B 6
how FileOutputStream and ObjectOutputStream working here
Serialization
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:40:18.