• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why not its ClassCastException?

 
m ali
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please anyone let me know why the following code not giving an error at compile time?


Thanks in Advance.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi Ali,
Try this,






Regards,
cmbhatt
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ali,




Try this code too,




Runtime type of the o1 is Stone that is Serializable; Allright!
No NonSerializable class exception at runtime!!!



Regards,
cmbhatt
 
m ali
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandra,

Thanks for your explanation.
In your 2nd explanation the Stone class is marked as Serializable, its ok.
Then what about 1st?, array(Object) is also implemented Serializable interfece?
I think, then only i can able to assign the object reference to Serializable reference. am i correct? please clarify?

Thanks in Advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic