Highbridge Capital Interview Question
Java DevelopersCountry: United States
Interview Type: Phone Interview
serial version UID
All the persistance capable classes are given a additional field called the serial version UID by the compiler
At the time of serializtion of an object to a Hard or a file this field will also be part of the serialized object
This field is used at the time we deserialize object
there is serial version problem gernerally occured
if we serialize an object it stores in the file system with that serial version UID.
in the mean time if we make any changes to the class and compile then the serial version UID changes
then a error will gernerate saying that invalid class exception as the serial version UID of the class and the object does not match
after serialization if u have altered the class like making non-transient instance variable to transient/alter the class hierachy etc then while deserialization InvalidClassException will come as system will compare deserialized class version with serialized one.So to avoid this we give our own versionId instead of default one,so that it wont change n u can still play around your class.
- sarthakiter July 26, 2012