• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Serializable

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

If anyone can explain me the below para,
"If you are a serializable class,but your superclass is NOT serializable, then any instance variable you INHERIT from that superclass will be reset to the value they were given during the original construction of the object.This is because the non-serializable class constructor WILL run."

thanks in advance,
Chand.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me show you what it means with an example.

Let's say you have a non-serializable Parent class



Now let's define a Child class, and make it Serializable:



Now let's define a Child object



Now, let's serialize the child object:



Now, let's deserialize it in the same object reference:



Now, let's print the deserialized object:



As you can see, the deserialization process did not set the value of the variable x, because it belongs to the Parent class, which is not serializable.

In other words, only the Child class was serialized.

I hope this helps!
 
reply
    Bookmark Topic Watch Topic
  • New Topic