1

Since abstract class and interface cannot be instantiated hence serialization is not applicable, however what is the purpose of allowing transient variables in abstract class?

  • 1
    Does this answer your question? [Why does Java have transient fields?](https://stackoverflow.com/questions/910374/why-does-java-have-transient-fields) – alea Aug 15 '20 at 18:47
  • 3
    What if you are serializing a child class? You would be okay with Java implicitly only serializing half your object, would you? That sounds like desirable behaviour, does it? – Michael Aug 15 '20 at 18:51
  • 1
    I think this will make it more clear https://stackoverflow.com/questions/36351555/transient-variable-inherited-and-subclass-is-serialized – Traycho Ivanov Aug 15 '20 at 19:03

1 Answers1

1

Because somebody might create a subclass that is not abstract and then instantiate it.