Difference Between Error and Exception


Ques:Difference between error and exception 
Ans: Error and Exceptions both areboth inherit fromThrowable..but they are differ by the following ways...
1.Error: Any departure from the expected behavior of the system or program, which stops the working of the system is an error.

Exception:Any error or problem which one can handle and continue to work normally.

2.An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist. Or a NullPointerException will take place if you try using a null reference. In most of the cases it is possible to recover from an exception (probably by giving user a feedback for entering proper values etc.).

3.Error's are irrecoverable exceptions. Usually a program terminates when an error is encountered. but exceptions are recoverable conditions.

4.Errors don't have subclasses while exception has two subclasses, they are compile time exception or checked exception (ClassNotFound Exception, IOException, SQLException etc.) and runtime or unchecked exception(ArrayIndexOutOfBounds Exception, NumberFormat Exception).

People who read this post also read :



1 comments:

Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog. It is very nicely explained. Your article adds best knowledge to our Java Online Training from India. or learn thru Java Online Training from India Students.

or learn thru JavaScript Online Training from India. Appreciating the persistence you put into your blog and detailed information you provide. Kindly keep blogging.

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More