• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compile time exceptions vs. Runtime exceptions

 
Matt Gottlieb
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am studying for the Java certification exam and I am having trouble determining when a runtime exception is thrown vs. a compile time exception.

I know certain exceptions are always checked exceptions, but it seems like others (e.g. Classcast Exception) can be either a runtime exception or a compile time exception.

If anyone can shed some light on this, it would be most appreciated.

Thank you,

-Matt
 
Paul Clapham
Sheriff
Pie
Posts: 20729
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as a "compile time exception". There are certainly error messages which can appear at compile time, but they are not exceptions and they are not thrown.
 
Helen Ma
Ranch Hand
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I agree that in most practice exam questions, you will be asked if there will be a class cast exception or compilation error.
For example,


I hope these examples will help.
 
Matt Gottlieb
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Helen Ma. That helps alot. I appreciate your help.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic