• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JVM, programmatic, runtime exceptions

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And here's the link to the JavaRanch Naming Policy
 
Jacky Zhang
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many of these are checked exceptions?
How is checked exception defined?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic