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

What is the order of method invocation in an Applet?

1 Answers  


What do negative exponents mean?

0 Answers  


what happens when we add the objects morethan the size limit to a hashmap

1 Answers  


What is the protected method modifier?

0 Answers  


What will be the output of round(3.7) and ceil(3.7)?

0 Answers  






can we write two same methods in outer class and innerclass.

1 Answers   3i Infotech,


Can you extend singleton class?

0 Answers  


Why string is called as immutable?

0 Answers  


How do you sort words in java?

0 Answers  


there are some duplicate values in ArrayList, how U'll get that array with out duplicate?

4 Answers   CMC,


When can we say that threads are not lightweight process in java?

0 Answers  


Can you call a method on a null object?

0 Answers  


Categories