This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
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

Doubt abt Serialization

 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Above code doesnot throw Exception at run time.
it serialize string array(obs)without implementing Serializable interface.
According to me it should throw runtime Exception(NotSerializableException).

Thanks.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are serializing a String array. It is the String array that has to be Serializable not class FileTest. If you print obs instanceof Serializable you will see that it returns true.
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok it means that String implements Serializable interface so TestFile
donot required to implement Serializable.

If TestFile class would be Serializing its data then Serializable interface would be required
is it so?
 
Naseem Khan
Ranch Hand
Posts: 809
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got it.
Thanks Everyone.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic