1Z0-829 Java I/O API and Securing Applications Practice Question
Exhibit
Exception in thread "main" java.io.InvalidClassException: com.example.User; local class incompatible: stream classdesc serialVersionUID = 5564992945715864724, local class serialVersionUID = -4978412458979645732
Refer to the exhibit. What is the most likely cause of this exception?
⚠ Common exam trap
Oracle often tests the misconception that any deserialization failure is due to file corruption or JVM version mismatch, when in fact the most common cause is an implicit `serialVersionUID` mismatch after a class definition change.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The class definition has changed and the serialVersionUID is not explicitly defined.
When a class definition changes (e.g., adding/removing fields) and the class does not explicitly declare a `serialVersionUID`, the JVM computes one automatically based on the class structure. After deserialization, if the computed UID differs from the UID stored in the serialized stream, an `InvalidClassException` is thrown. This is the most common cause of deserialization failures in practice.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The serialized object is corrupted.
Why it's wrong here
Corruption would cause StreamCorruptedException, not InvalidClassException.
- ✗
The JVM versions are incompatible.
Why it's wrong here
JVM version differences do not cause serialVersionUID mismatch; the UID is computed from the class, not the JVM.
- ✗
The file contains data that is not a serialized object.
Why it's wrong here
This would cause ClassNotFoundException or stream corruption errors.
- ✓
The class definition has changed and the serialVersionUID is not explicitly defined.
Why this is correct
Without an explicit UID, the JVM computes one from the class definition, which changes when the class is modified.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.