Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization details

 
Kunaal A Trehan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Consider a case
-class B extends A

Class A implements Serializable .But class B does not
Can class B be serialized?

Consider the same case.But Class B implements Serializable.
But class A does not implement Serializable.
Can class B be serialized?

Any pointers would be helpful

Cheers
Kunal
 
Steve McCann
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say Yes in both cases:
-class B extends A
Class A implements Serializable .But class B does not

Class B therefore is serializable, as it is a subclass of A, which implements the interface.
Consider the same case.But Class B implements Serializable.

Yes, class B can be serialized, regardless of whether class A implements Serializable or not as class B implements the interface.

Steve
[ July 29, 2005: Message edited by: Steve McCann ]
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In both the cases, B can be Serialized
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic