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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain jvm, jre, and jdk?

678


What is the difference between private & public & friendly classes?

647


Is java a pure object oriented language?

621


How do you sort objects in java?

616


What does system.gc() and runtime.gc() methods do?

702






What is difference between == equals () and compareto () method?

627


What is native method in java?

658


Why we cannot override static method?

652


What is supplier in java?

647


What is a local, member and a class variable?

662


What is the difference between an interface and an abstract class?

635


What is an infinite loop?

633


What will happen if static modifier is removed from the signature of the main method?

608


What are static variables and functions?

716


Difference between doublesummarystatistics, intsummarystatistics and longsummarystatistics ?

651