Transient Keyword comes into existence in case of Serialization. It plays very important role in Serialization. We have also mentioned the differences with static and final keyword. If someone is going to ask you about transient then it can not be out of this context. It is the complete explanation of transient one can give.
Transient keyword:
a) transient is a modifier applicable only for variables.
b) At the time of Serialization if we don't want to save the value of a particular Variable to meet security constraints then we should go for transient keyword.
c) At the time of Serialization JVM ignores Original value of transient variables and save default value to the file.
d) Hence transient means not to Serialize.
static vs Transient:
a) Static variables are not part of Object State and Hence they won't Participate in Serialization.
b) Due to this declaring a static variable as transient is of no use.
final vs transient:
a) final variables will participate in Serialization directly by their values.
b) Due to this declaring a final variable as transient if of no use and no impact.
Transient keyword:
a) transient is a modifier applicable only for variables.
b) At the time of Serialization if we don't want to save the value of a particular Variable to meet security constraints then we should go for transient keyword.
c) At the time of Serialization JVM ignores Original value of transient variables and save default value to the file.
d) Hence transient means not to Serialize.
static vs Transient:
a) Static variables are not part of Object State and Hence they won't Participate in Serialization.
b) Due to this declaring a static variable as transient is of no use.
final vs transient:
a) final variables will participate in Serialization directly by their values.
b) Due to this declaring a final variable as transient if of no use and no impact.
0 comments:
Post a Comment