I faced this question in an interview. Please help me to find the answer. The question was Can a transient variable be serialized in any way?
static
and transient
fields are not serialized by default.
However they can be serialized if
static
fields, though I have written such a library by mistake once)Usually a field is made transient
to mean it shouldn't be serialized, though sometimes it might be because
Serializable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With