why to use transient variables when static variables can be
used for Serialization
Answer Posted / ram
Both static & Transient are may not be serialized.
Static means one per class not one per object. Static
variables are not saved and when an object is deserialized,
it will have whatever static variable its class currently
has. Don’t make serializable objects dependent on a
dynamically-changing static variable. It might not be the
same when the object comes back.
Transient variables are given a value of NULL for object
references and defaults (0, false, etc) for primitives.
Is This Answer Correct ? | 12 Yes | 4 No |
Post New Answer View All Answers
What is early binding and late binding in java?
Why 1 is not a prime number?
What about static nested classes in java?
What are keyboard events?
What is __ init __ functions?
What is qms certification?
What is the tradeoff between using an unordered array versus an ordered array?
What is meant by string is immutable?
How to perform binary search in java?
Can an anonymous class be declared as implementing an interface and extending a class in java programming?
What is covariant return type?
What is the difference between import java.util.date and java .util?
What are the access modifiers in java?
how does multithreading take place on a computer with a single cpu? : Java thread
What is illegal identifier in java?