I was asked this question in an interview. The interviewer wanted to know how to make an object immutable. and then he asked what if I serialise this object - will it break immu
An immutable object is one which cannot be changed once created. You can create such an object by using private
access modifiers, and the final
keyword.
If an immutable object was serialized, its raw bytes could be modified so that upon deserialization the object is no longer the same.
This can't be prevented completely. Encryption, checksums, and CRC's will help to prevent this though.