Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Why not its ClassCastException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Why not its ClassCastException?" Watch "Why not its ClassCastException?" New topic
Author

Why not its ClassCastException?

m ali
Ranch Hand

Joined: Apr 12, 2007
Posts: 49
Hi,

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


Thanks in Advance.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707


Hi Ali,
Try this,






Regards,
cmbhatt


cmbhatt
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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

Joined: Apr 12, 2007
Posts: 49
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why not its ClassCastException?