Serialization is a Java technique that turns an object into a byte stream. Both the instance's data and the kind of data stored there are included in the byte stream. The exact opposite action is taken by deserialisation. It transforms the original object data from the byte sequence. A transient keyword can be used during serialization to prevent an object from being serialized. Write a comment Why use the transient keyword? The transient keyword can be used with the data members of a class to avoid their serialization. For example, if a program accepts a user’s login details and password. But we don’t want to store the original password in the file. Here, we can use the transient keyword and when JVM reads the transient keyword it ignores the original value of the object and instead stores the default value of the object. Syntax: privatetransient<member variable>; Or transient private<member variable>; When to use the transient keyword? The transient modifier can be used where there are data members derived from the other data members within the same instance of the class. This transient keyword can be used with the data members which do not depict the state of the object. The data members of a non-serialized object or class can use a transient modifier.