| The volatile keyword against the variable indicates that the content of the variable is stored in the main memory and every read of the variable should be done from the main memory and not the CPU cache and every write should be written to the main memory and not just to the CPU cache. | Transient is used when we do not want the variable to be serialised. |
| Volatile ensures that the JVM does not re-order the variables and ensures that the synchronization issues are avoided. | Transient provides flexibility and control over the attributes of objects from being serialized. |
| Volatile variables do not have any default values. | Transient variables are initialized with default value corresponding to the data type at the time of deserialization. |
| Volatile variables can be used along with the static keyword. | Transient variables cant be used along with static keywords because the static variables are class-level variables and not related to the individual instances. This matters during serialization. |
| Volatile variables can be used along with the final keyword. | It is not recommended to use final with transient variables as it would cause problems for re-initializing the variables once the values are populated by default at the time of deserialization. |