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 widening and narrowing in java? Discuss with an example.

649


Is a method a procedure?

653


how do I create a runnable with inheritance? : Java thread

627


When is an object subject to garbage collection?

674


explain different ways of using thread? : Java thread

653






How we can execute any code even before main method?

643


Can we create a class inside a class in java?

639


How can you add and remove nodes in jtree?

704


What is difference between protected and private?

636


What is independent and dependent variables in research?

554


What is singleton class in ruby?

682


Is 0 an even number?

656


What are operators and its types?

662


Explain the hierarchy of java exception classes?

699


What is meant by JVM? Is JVM platform independent or not?

682