What is RuntimeException??Can we consider all the exceptions which occur at runtime are RuntimeExceptions like ArrayIndexOutOfBoundsException.What is the difference between JVM thrown exceptions and RuntimeExceptions??JVM thrown Exceptions also occur at runtime.I am confused with these two types of exceptions .. Can anyone clarify this?? Thanks in advance..
Joined: Mar 26, 2007
In general, an exception happens because some resource is not available or some other condition required for correct execution is not present
A checked exception must be caught somewhere in your code. If you invoke a method that throws a checked exception but you don't catch the checked exception somewhere, your code will not compile. That's why they're called checked exceptions; the compiler checks to make sure that they're handled or declared.
A runtimeException is not handled by compiler, it could come as a programming logic, like if you try to access array element, which index is greater than the size of array(ArrayIndexOutOfBound Exception). So user has to handle this kind of exception by his/her logic.If not, the program will not execute at runtime.
One more thing checked exception is handled at compile time(when you try to compile your file for ex javac filename), but runtime exception will occur at runtime(when you execute your program for ex Java filename)