File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions doubt 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 "Exceptions doubt" Watch "Exceptions doubt" New topic

Exceptions doubt

Mamadou Touré
Ranch Hand

Joined: Dec 27, 2007
Posts: 189
I found in several mock exams the question gives a list of exceptions and asks to say which ones are programmer's and which ones are JVM's. So is there a simple way to distinguish them, or should I know them by heart ??


SCJP 5 (76%)
SCWCD 5 (86%)
SCBCD 5(70%)
"The greatest glory in living lies not in never falling, but in raising every time we fall.".. Nelson Mandela
Eduardo Mendes
Ranch Hand

Joined: Apr 30, 2008
Posts: 30
You can find some background on this in the K&B book, pages 368-369. Personally, I also struggled sometimes to distinguish ones from the others.

Anyway. This is how I understand it. A programmer exception is one created specifically to address a program-logic situation (e.g. you get the arguments into your method not formatted properly, or you define a new type of exception to deal with a special/exception case in your application's logic). On the other hand, a NullPointerException is the typical JVM exception, which is not related to any particular program-logic situation, but rather raises an issue the JVM encountered when trying to execute the program.

A bit confusing, I admit, but hope this helps somehow.
Hemnathbabu Kottaiveedu

Joined: Mar 13, 2008
Posts: 28

From SCJP exam point of view if you want to remember the exception type you can use this tip:

Following are the exceptions thrown programatically:


NumberFormatException(Subclass of IllegalArgexp)

IllegalStateException and

AssertionError (This is simple to remember)

All other 6 exceptions are thrown by JVM.

Hope this helps you.

SCJP 5 (100%)
Mamadou Touré
Ranch Hand

Joined: Dec 27, 2007
Posts: 189
still confused a little bit
Eduardo Mendes
Ranch Hand

Joined: Apr 30, 2008
Posts: 30
This is a good example of a JVM exception: java.lang.NullPointerException

A good example of a programmer exception: com.mypackage.UserNotLoggedIn

I try to distinguish ones from the others by looking at the JVM exceptions as generic exceptions, that do not relate to any particular failure in the program logic, and to the programmer exceptions as exceptions created to signal a specific error related to the program logic.

- a NullPointerException signals that the JVM tried to invoke a method on a reference that points to null
- a com.mypackage.UserNotLoggedIn was created by the programmer to signal that a certain anonymous user tried to do an operation which requires him to be logged in.
I agree. Here's the link:
subject: Exceptions doubt
It's not a secret anymore!