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 meant by object oriented programming – oop?

543


What is the difference between the paint() and repaint() methods?

583


Which is easier .net or java?

641


Can I import same package/class twice?

492


does java support pointers?

561






Why scanner is used in java?

548


What is equals method in java?

522


What is byte data type?

548


What are the two types of java?

515


What is overriding in java?

518


Write a program to print count of empty strings in java 8?

535


Can a boolean be null java?

539


4.1 Supply contracts (in the form of comments specifying pre- and post conditions) for the enqueue() method of the LinkedQueue class given in the Appendix. (2) 4.2 Let Thing be a class which is capable of cloning objects, and consider the code fragment: Thing thing1 = new Thing(); //(1) Thing thing2 = thing1; //(2) Thing thing3 = (Thing) thing1.clone(); //(3) Explain how the objects thing2 and thing3 differ from each other after execution of the statements. (

1406


What is class and object in java?

549


What is structure of java heap? What is perm gen space in heap?

538