What is serialVersionUID and what is its need?



What is serialVersionUID and what is its need?..

Answer / javamasque

The serial version UID is metadata about the serializable object, it is hash code for the serializable object. It contains information about class name, field name, field type, implemented interfaces and super classes. For each modification to serializable object, we have to update serial version UID explicitly. If we do not provide any serial version UID, JVM’s default serialization mechanism generates serial version UID for the object at runtime.

During deserialization, JVM matches the serial version UID from object stream with the serializable object which will receive the stream data. If there is a mismatch in serial version UID, JVM throws InvalidClassException

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More Core Java Interview Questions

Have you ever used hashtable and dictionary?

0 Answers  


why string constant pool in java

2 Answers   TCS,


Can you pass functions in java?

0 Answers  


Is 0 true or is 1 true?

0 Answers  


Is singleton class thread safe?

0 Answers  






do I need to use synchronized on setvalue(int)? : Java thread

0 Answers  


Explain the difference between abstract class and interface in java?

0 Answers  


Do extraneous variables affect validity?

0 Answers  


How do you sort a string in alphabetical order in java?

0 Answers  


How to count occurrences of each duplicate element in a list {a,b,d,c,a,b} ? Thanks in Advance

2 Answers   TCS,


What happens when you assigned a 'double' value to a 'String'?

8 Answers  


Is heap stored in ram?

0 Answers  


Categories