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 default size of arraylist in java?
How to convert string to char and vice versa?
Explain the protected field modifier?
What is a cup of java?
Which one of the following suits the description of a string better: derived or primitive?
Can java program run without jre?
What is jit and its use?
What is difference between path and classpath in java?
what are three ways in which a thread can enter the waiting state? : Java thread
What happens when I use / and % with a negative numerator?
What is singleton class in java and how can we make a class singleton?
if u open login & logout ,how can udisplay the timelogin & logout members ?
What is static import?
How do you use nextline in java?
I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?