why to use transient variables when static variables can be
used for Serialization

Answers were Sorted based on User's Feedback



why to use transient variables when static variables can be used for Serialization..

Answer / lenina

only non static and non transient variables can be serialized.

if we want a variable to be instance variable,but the
variable is non serializable variable, then we declare that
variable as transient. here exactly we can make use of
transient.

Is This Answer Correct ?    26 Yes 7 No

why to use transient variables when static variables can be used for Serialization..

Answer / 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

why to use transient variables when static variables can be used for Serialization..

Answer / priyanjan

static variables can also serialized but is a very
cumbersome process. Transient keyword prefixing any
variable states that the varible does serialized but its
state i.e. value of the varible, does not serialize.

Is This Answer Correct ?    10 Yes 7 No

why to use transient variables when static variables can be used for Serialization..

Answer / yogesh

A transient variable is a variable that may not be serialized.

Is This Answer Correct ?    4 Yes 6 No

Post New Answer

More Core Java Interview Questions

What are the different approaches to implement a function to generate a random number?

0 Answers   Axtria, ITC Indian Tobacco Company,


Write a java program to check if a number is prime or not?

0 Answers  


Difference between this(), super()?

12 Answers   College School Exams Tests, Oracle,


What is meant by Session? Explain something about HTTP Session Class?

1 Answers  


What is a method signature java?

0 Answers  






Explain exception chaining in java?

0 Answers   Cyient,


What is the r character?

0 Answers  


1) There are 10 different threads in runnable state. Each having priority 1 to 10. How does the CPU schedules or executes these threads?

2 Answers   RBS,


How does queue work in java?

0 Answers  


What are the benefits of operations in java?

0 Answers  


Explain about data types?

0 Answers  


what is mean by String and StringBuffer? What is mean by Methooverriding and Overloading?

2 Answers   Satyam,


Categories