2

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?

3
  • 1
    Does this answer your question? Why does Java have transient fields? Commented Aug 15, 2020 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? Commented Aug 15, 2020 at 18:51
  • 1
    I think this will make it more clear stackoverflow.com/questions/36351555/… Commented Aug 15, 2020 at 19:03

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments