What is main difference between runtime exception and runtime error in java? | SoloLearn: Learn to code for FREE!

+1

What is main difference between runtime exception and runtime error in java?

I have read on websites that error cannot be recovered by any handling technique and it have only one type that is unchecked exception if error has exception than it can be handled as well so why it is written that error cannot be recovered by handling technique?

5/4/2020 8:47:09 AM

Subhan Ahmed

1 Answer

New Answer

+2

Error and Exception both implement the throwable interface. If you can catch exceptions then certainly you can catch errors as well. Now see, catching errors is not considered a good practice because it is very difficult to know what type of error is going to occur. But you can generally predict a type of exception that is going to occur. https://javarevisited.blogspot.com/2014/02/why-catching-throwable-or-error-is-bad.html https://stackoverflow.com/questions/10956896/can-an-error-be-handled-in-the-same-way-as-an-exception