I dont think I can better specify the question...
Asked
Active
Viewed 95 times
-2
-
3Maybe you can find the answer here: http://stackoverflow.com/questions/2190161/difference-between-java-lang-runtimeexception-and-java-lang-exception – Keppil Dec 30 '15 at 15:37
2 Answers
0
There are a lot of such exceptions are called "runtime exceptions". RuntimeException
for an example.

v.ladynev
- 19,275
- 8
- 46
- 67
-
-
@suspicious read [`RuntimeException`](https://docs.oracle.com/javase/8/docs/api/java/lang/RuntimeException.html): *RuntimeException and its subclasses are unchecked exceptions. Unchecked exceptions do not need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary*. – Luiggi Mendoza Dec 30 '15 at 15:42
-
-
But what does default exception throwing has to do with the fact that they are unchecked? I think you are confusing the question. And don't mark it a duplicate luiggi. ITS NOT! – suspicious Dec 30 '15 at 15:51
-
-
@v.ladynev let me demonstrate with an example. I have a method called division() that performs a division by zero. I call this method from the main method. In the division() method i have not included a "try{ } catch() { }" block, nor have I included the "throws ArithmeticException" when declaring my method. But when I call the method from main it goes like this: try { division(); } catch(ArithmeticException e) { System.out.println("Division by zero detected"); } And even though I have not used "throws ArithmeticException" when declaring my method, the exception handling in "main" worked – suspicious Dec 30 '15 at 16:03
-
@suspicious In the real systems you will not do such kind of things `try { division(); } catch(ArithmeticException e) { System.out.println("Division by zero detected"); } ` you will just allow an `ArithmeticException` goes to the top level :) Exception "worked" because of the type of it "runtime exception". – v.ladynev Dec 30 '15 at 16:06
-
@v.ladynev It doesn't matter what you do in real life for christ's sake. Did you ven understand me? – suspicious Dec 30 '15 at 16:08
-
@suspicious I am not sure. Ok. You don't need to declare `ArithmeticException` in the `throws` clause because of it descendant of `RuntimeException`. – v.ladynev Dec 30 '15 at 16:11
-
@v.ladynev so the main function, in my example (with is the caller) will deal with the exception anyway, even if the division() method doesn't declare "throws Arithmetic Exception" ? – suspicious Dec 30 '15 at 16:14
-
@suspicious Yeah. You got it. Checked exceptions are bullshit in my opinion. You should always be ready to have an exception rising in any part of the code. – v.ladynev Dec 30 '15 at 16:18
-
-
0
Yes. Anything inherited from RuntimeException
or Error
.
The first means some unhandled issues in your code, the Error means serious problem with JVM like out of memory, stack overflow etc.

Zbynek Vyskovsky - kvr000
- 18,186
- 3
- 35
- 43
-
-
-
Well, you're right guys. But I think it's worth mentioning that there are other classes apart from Exception which can surprise you and your code should be aware of – Zbynek Vyskovsky - kvr000 Dec 30 '15 at 15:44