In my interview i got one question how to achive Serialization and I gave answer as
public class SerializationSample {
public static void main(String args[]) {
...........
FileOutputStream fos = new FileOutputStream(outFile);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(serializableObject);
............
}
class SerializationBox implements Serializable {
............
............
}
but the interviewer told, this will serialize whole object and he asked 2 questions
Please any one can help me to finding answer for this question
Let me quote an essence from similar and already answered question
The serialVersionUID represents your class version, and you should increment it if the current version of your class is not backwards compatible with its previous version.
and
automatically-generated UID is generated based on a class name, implemented interfaces, and all public and protected members. Changing any of these in any way will change the serialVersionUID. So you don't need to mess with them only if you are certain that no more than one version of the class will ever be serialized (either across processes or retrieved from storage at a later time).
I recommend you to visit that link and, as always, search the web.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With