← Back to libraryQuestion 20 of 273
JavaIntermediate

Serialization

📖 Detailed Explanation:

Serialization converts an object's state into a byte stream so it can be saved to a file, transmitted over a network, or stored in a database. Classes must implement the Serializable marker interface. The 'transient' keyword prevents specific fields from being serialized (useful for sensitive data like passwords).

🌍 Real-World Example:

Taking a snapshot of a person at a specific moment and storing it on film. Later, you can recreate that exact state from the film.

🎯 Scenario-Based Interview Question:

What is the purpose of 'serialVersionUID' in a Serializable class? What happens if you change the class structure?