Q72: How does Serialization work, and what is the role of transient and serialVersionUID?
Serialization transforms object state into a byte stream (ObjectOutputStream).
serialVersionUID: Unique version identifier verifying that sender and receiver loaded compatible class definitions during deserialization (InvalidClassExceptionon mismatch).transient: Keyword applied to fields that MUST be skipped during serialization (e.g., passwords, transient caches).
Key Takeaways
serialVersionUIDverifies class compatibility during deserialization.transientfields are excluded from serialized byte streams.
Knowledge Check
What value does a transient int variable hold upon being deserialized from a byte stream?