Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

a test about casting

 
Domingo zhou
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

why the code "pogo = (SwampThing)wawa;" will cause runtime exception but not a complile time error.
i think,the "wawa" is Washer type thich is not relevant to the
hierarchy from "animal" to "Swampthing".so the explicit casting will cause
complile error.But im am wrong.
Why???
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!