UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

what is serialVersionUID , why it different for each bean? serialVersionUID = 42L;

Asked by Last Modified  

15 Answers

Learn Java

Follow 0
Answer

Please enter your answer

JAVA Interview and other

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the...
read more
The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long: ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L; If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID fields are not useful as inherited members. read less
Comments

Tutor

This id is used to identify the type of the class. This is required when you serialize and de serialize the object. If you have given a value to this id, this will be common for all the objects created out of this class. Please note this id is a static field.
Comments

It represents the version number of the class. It mainly used during serialization and deserialization.
Comments

Java/J2EE Corporate Trainer

Serialization is a mechanism in java where an object can be represented as a sequence of bytes that includes the object's data as well as information about the object's type. Once an object is serialized its written to a file which can later be again deserialized to recreate the object in the memory. Consider...
read more
Serialization is a mechanism in java where an object can be represented as a sequence of bytes that includes the object's data as well as information about the object's type. Once an object is serialized its written to a file which can later be again deserialized to recreate the object in the memory. Consider a distributed hosting platform where web application is deployed across multiple servers. Each server has its own JVM container and they need to share common data (for ex - session object data), to serve the incoming requests. This objective is achieved using serialization. Each serialized class is associated with a version number, called a serialVersionUID which is used during deserialization to verify that the receiver has loaded the very class that the sender had intended. In case the receiver has loaded a class with different serialVersionUID, than that of corresponding sender class, then it'll result in InvalidClassCastException. If no serialVersionUID has been assigned, a default value gets assigned by the compiler. However, as a best practice, it is strongly recommended that all serializable classes explicitly declare serialVersionUID since the default serialVersionUID computation is highly sensitive and may also vary across various java compiler implementations. read less
Comments

Technical Subjects & Programming Languages Expert

It represents the version number of the class. It mainly used during serialization and deserialization.
Comments

Sr. Communication Trainer

Bean is a container of java classes. some java classes are not updated in the serial version UID ...This is a kind of ID to tell about the latest version and the java classes contained in the bean.
Comments

Java J2EE

The serialVersionUID have to match during the serialization and deserialization process. The serialVersionUID is used as a version control in a Serializable class. If you do not explicitly declare a serialVersionUID, JVM will do it for you automatically, based on various aspects of your Serializable...
Comments

IT tutor

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L; serialVersionUID is a static final field. You can assign any number of your choice to it. serialVersionUID is a must in serialization process. But it is optional for the developer to add it in java source file. If you are not going to...
read more
ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L; serialVersionUID is a static final field. You can assign any number of your choice to it. serialVersionUID is a must in serialization process. But it is optional for the developer to add it in java source file. If you are not going to add it in java source file, serialization runtime will generate a serialVersionUID and associate it with the class. The serialized object will contain this serialVersionUID along with other data. Even though serialVersionUID is a static field, it gets serialized along with the object. This is one exception to the general serialization rule that, “static fields are not serialized”. serialVersionUID is a 64-bit hash of the class name, interface class names, methods and fields. Serialization runtime generates a serialVersionUID if you do not add one in source. Refer this link for the algorithm to generate serialVersionUID. It is advised to have serialVersionUID as unique as possible. Thats why the java runtime chose to have such a complex algorithm to generate it. read less
Comments

Masters in IT from UK

I agree with Chinna
Comments

6yrs exp in j2ee

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the...
read more
The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long: - See more at: https://www.urbanpro.com/java/what-is-serialversionuid-why-it-different-for-each?id=138664&_from=showMessage#.dpuf read less
Comments

View 13 more Answers

Related Questions

What are the best books for learning programming languages like C (except let us C), Java, Python, etc.?
you can read "Head First Java",I do read it even now after having 6 years of working experience in Java when I want to refresh some concept. you can also read Core Java, Volume 1 and 2 by Cay S. Horstmann,...
Shashank
0 0
6
What are the advantages of learning Java?
Dear Niteen Java is one of the most widest implemented technology for programming. Not only its used to develop full fledged Software Applications, but its also used for programming devices like Set...
Niteen
0 0
6
Is it good to go for a Java coaching center and learn Java (with advanced Java) to improve my programming skills?
yes, Please check the Institute reviews and discuss with the tutor, what topics were covered in class. Ask about the practicals session and how many hours/duration of the course.
Gerda
0 0
5
Which is a good Java training and placement institute for a fresher in Bangalore?
I know an institute in HYderabad which is giving 100% job guarantee or 100% fee refund. They have office in bangalore also, not sure whether they are offering this program in Bangalore. Please visit their...
Raja
0 0
5
hat is java
Introduction to JAVA Programming concepts of Basic Java Language Features Data Types, Variables Control Statements OOPS Concepts Writing your own Java Classes Object...
Narendra
0 1
8

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

GIT
In software engineering, software configuration management (SCM) is the task of tracking and controlling changes in the software, part of the larger cross-disciplinary field of configuration management....
R

Why Should We Learn Java Language?
Most of starters has confusion today that which of the programming language should be chosen to work on. It totally depends upon your need. As per my opinion, if you want to grow your career in IT industry...

Syntax and example of java
Java syntax: Class Display - - class definition { Void Display() { System.out.println('welcome to Java') ; } Public static void main(String arcs) { Display D=new Display() ;--object creation D. Display } }

Mastering in Java Programming
Core java topics What is Java?Execution Model Of JavaBytecodeHow to Get Java?A First Java ProgramCompiling and Interpreting ApplicationsThe JDK Directory StructureUsing Eclipse Data types and Variables What...

How do i get best Campus / Off Campus Placement?
Companies are looking for Skilled Freshers. So build your technical skills while doing MCA / BTech / BCA / BSc (IT or CS) into below areas- 1. Strong your programming & debugging skills ...

Recommended Articles

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more