aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JVM, programmatic, runtime exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JVM, programmatic, runtime exceptions" Watch "JVM, programmatic, runtime exceptions" New topic
Author

JVM, programmatic, runtime exceptions

Jacky Zhang
Greenhorn

Joined: Sep 17, 2006
Posts: 18
I understand the following:

JVM exceptions Those exceptions or errors that are either exclusively or most logically thrown by the JVM.
NullPointerException,
StackOverflowError,
ArrayIndexOutOfBoundsException,
ClassCastException,
ExceptionInInitializerError,
NoClassDefFoundError.

Programmatic exceptions Those exceptions that are thrown explicitly by application and/or API programmers.
NumberFormatException,
AssertionError,
IllegalArgumentException,
IllegalStateException.

But then when it says "it�s okay for the overriding method to throw any runtime exceptions." i got the question:

What are runtime exceptions as far as JVM and programmtic exceptions mentioned above is concerned?

Are programmatic exceptions all runtime exceptions? what about JVM exceptions? are they not runtime exceptions?
Neelesh Bodas
Ranch Hand

Joined: Jul 20, 2006
Posts: 107
Originally posted by enen:
What are runtime exceptions as far as JVM and programmtic exceptions mentioned above is concerned?


Limiting ourselves only to the 10 Throwables listed above, all the exceptions in the above list are RuntimeExceptions. Note that the list has 4 errors and 6 exceptions.

Also note that all the 10 Throwables in the above list can be thrown fromanywhere without declaring or handling them.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
Hi enen,

We'd like you to change your display name to meet our naming policy!

We've found it keeps the ranch friendlier

Good luck in your studies,


Bert


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
And here's the link to the JavaRanch Naming Policy


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Jacky Zhang
Greenhorn

Joined: Sep 17, 2006
Posts: 18
How many of these are checked exceptions?
How is checked exception defined?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Originally posted by Jacky Zhang:
How many of these are checked exceptions?
How is checked exception defined?


A runtime exception is an exception that IS-A RuntimeException -- meaning an object that is either that class type or subclass of that type.

The significance of the RuntimeException class is that the compiler will not require you to declare that you throw that exception, or require you to catch it. It is basically an "unchecked" exception.

A "checked" exception is an exception that is not an "unchecked" exception -- or an exception that is not a RuntimeException.


[EDIT: new text below]

Just realize that this thread also refers to errors.

An Error is a throwable object that IS-A Error -- meaning an object that is either that class type or subclass of that type.

Like runtime exceptions, it is also unchecked. However, it is separated from runtime exceptions because it is *not* recommended that you catch these, as they generally indicate an abnormal condition that may not be recoverable.

Henry
[ September 20, 2006: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
Hi Jacky,
"Are programmatic exceptions all runtime exceptions?"
It depends :
There is an actual class called RuntimeException. If a particular exception entends this, then it is a runtime exception. Examples include ArrayIndexOutOfBoundsException & NullPointerException. There are not checked exceptions in that they dont need to be declared as a possible exception that could be thrown from a method. Similarly the dont need to be handled by the calling method with an explicit catch or declare.

"what about JVM exceptions? are they not runtime exceptions?"
Some of them are - ArrayIndexOutOfBoundsException, NullPointerException as mentioned. However, StackOverflowError is an error, not an exception. Errors are far more serious and shouldnt really be handled by application.

Anyway - StackOverflowError, what could you do?!!

Tom


<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JVM, programmatic, runtime exceptions