What is serialVersionUID and what is its need?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between stored procedure & function?

541


Can we call a non-static method from inside a static method?

553


How is abstraction implemented in java ?

532


What is the difference between iterator and enumeration ?

506


How do you define a parameter?

576






What is difference between string and new string?

528


Describe the term diamond problem.

569


What does java ide mean?

629


How strings are created in java?

553


Can a variable be local and static at the same time?

534


Can a class be a super class and a sub-class at the same time? Give example.

786


What does the exclamation mark mean in java?

585


Can you run java program without main method?

540


hr interview how many minutes asking question

1558


Is hashset ordered java?

577