Answered Questions

  • what is a transient variable

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

    Star Read Best Answer

    Editorial / Best Answer

    sivagopal  

    • Member Since Jun-2009 | Jun 8th, 2009


    A variable that won't be allowed for object serialisation. so that the state of the value will always be defaulted after the deserialisation.
    For example a variable x's value is set to 9, it's default value is '0' say, when the object has been serialized having x's value 9, after deserialisation will be defaulted to '0'

    Use: In Java, serialization of an object allowed only when all the underlying objects of the object that is currently under serialization contains has a relationship, will not be allowed, some times the developer has no choice of implementing serializable marker interface on some classes as the classes might have been arrived from a third party and the developer has no control over them, but the developer needs to serialize the object's state, then the developer has the choice of marking the objects that not serializable as transient.

    Yogesh Bombe

    • Aug 11th, 2015

    A transient variable is a variable that cannot be serialized. The transient keyword can be used to indicate the Java Virtual Machine that the variable is not part of the persistent state of the object.

    raisha

    • May 6th, 2013

    transient is a keyword....If a variable is declared as a Transient ,we cant serialize that variable.. The important points about Transient are: 1) Transient keyword can only be applied to fields or ...