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
Why parameters should be passed by reference?
Is string pool garbage collected?
What is the inheritance?
How are observer and observable used in java programming?
What is not thread safe?
What is difference between checked and unchecked exception in java?
Why java is said to be pass-by-value ?
What do you mean by stream pipelining in java 8?
State some advantages of java?
What do you know about the garbate collector?
Why parsing is done?
In a class implementing an interface, can we change the value of any variable defined in the interface?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
What is the purpose of the enableevents() method in java programming?
Why we use methods in java?