Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Compile time exceptions vs. Runtime exceptions 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 "Compile time exceptions vs. Runtime exceptions" Watch "Compile time exceptions vs. Runtime exceptions" New topic
Author

Compile time exceptions vs. Runtime exceptions

Matt Gottlieb
Greenhorn

Joined: Dec 25, 2011
Posts: 10

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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Nov 01, 2011
Posts: 451
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

Joined: Dec 25, 2011
Posts: 10
Thank you Helen Ma. That helps alot. I appreciate your help.

 
 
subject: Compile time exceptions vs. Runtime exceptions