This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface Serialization and Object extensions  RSS feed

 
graham king
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a general question on serialization and objects which implement an Interface that extends the Seriazable Interface.

If I create an Interface myInt that extends Serializable and then implement the myInt interface with aClass, will the aClass also follow the basic serialization protocol or would it need to implement the Serializable interface as well?

Thanks,

Graham
 
graham king
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry.

Actually. I have IOne that implements Serializable. And ITwo that extends IOne. Is ITwo also Serializable.

Thanks.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Serializable interface is inherited, so you don't need to "implement" it again. This is also easy to check:
By the way, I hope your interfaces as classes don't start with lowercase letters!
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just saw you second post. Second verse, same as the first
Again, when it's easy to test a hyposthesis, do test it!
 
graham king
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeff! That was easy.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!