If we declared a variable as
transient String x = "abc"
then it will suppress serialization
but if declare as
transient static String x = "abc"
then this variable get serialized .
Please explain this.
No it doesn't. If you change it dynamically to "xyz" and then serialize the object, it will still be "abc" at the receiver. Ergo no serialization is taking place. What is happening is that the class is loaded in its initial state when loaded on the receiving end.