Name of the modifier which is used only for the variable in Java?

Transient, it is used in the serialization concept.  At the time of serialization, if we don’t want to save value of a particular variable in a file, then we use transient keyword. When JVM comes across transient keyword, it ignores original value of the variable and save default value of that variable data type.

A transient modifier applied to a field tells Java that this attribute should be excluded when the object is being serialized. When the object is being deserialized, the field will be initialized with its default value (this will typically be a null value for a reference type, or zero/false if the object is a primitive type).

transient keyword plays an important role to meet security constraints. There are various real-life examples where we don’t want to save private data in file.

Another use of transient keyword is not to serialize the variable whose value can be calculated/derived using other serialized objects or system such as age of a person, current date, etc.

Practically we serialized only those fields which represent a state of instance, after all serialization is all about to save state of an object to a file. It is good habit to use transient keyword with private confidential fields of a class during serialization.

Example:

class Test implements Serializable 
{ 
    private transient String password; 
    transient int age; 
  
    private String username, email; 
    Date dob;
}