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 restrictions are placed on method overriding in java programming?
describe synchronization in respect to multithreading? : Java thread
What are the files generated after using IDL to java compiler?
What is nested interface?
What is private protected in java?
Why are parameters used in functions?
Can I override protected method in java?
What is the size of boolean variable?
Can you have two constructors in java?
Can constructor be protected in java?
Where will it be used?
Which list does not allow duplicates in java?
What are the uses of java?
Tell me how many ways are there to initialise an integer with a constant.
What does compareto () do in java?