What is transient variable?

What is transient variable?

A variable is said to be ‘transient’, which is not participated in object serialization. The variable with ‘transient’ access modifier is not persisted onto the object. Frequently updating values in a Java application will not be serialized by practice. Such variables can be specified as transient.

What is transient variable?

A variable declared as "transient" in a Serializable class cannot be serialized although the class is declared as serializable.

When the class is written to an ObjectStream, the value of the variable can't be written to the stream and when the class is retrieved from the ObjectStream the value of the variable becomes null.
Difference between static and non-static variables
A static variable is shared among all instances of a class...
What is inheritance? Explain it with an example
What is inheritance? - Through inheritance, classes can inherit commonly used state and behavior from their parent class...
What is an overloaded method? Provide an example to explain it
What is an overloaded method? - Overloaded methods are the methods which have the same name but different signatures...
Post your comment