What is a transient variable?

The lexical meaning of word transient is 'existing for a short duration',in Java,a transient variable is one which one would not like to be saved during seralization.This is mostly the case when a variable is sensitive enough that it should not be saved during serialization, such as a password.Even when such variable is private in the object,once it is serialized it is possible to read it inside a file or over a network.The keyword 'transient' is solution for such variables that are not required to be serialized.



Interview Questions On Java,Java EE Copyright © 2018. Reads: best tracker