Hey there! any question in your mind? Ask It Now!.

Popular Categories

What is the Difference between Error And Exception?

+7 votes
asked in Programming by mannu (990 points)
edited by Bhartesh
Now a days we usually meet these words in our code Error or Exception do we know the exact meaning of these words?

So guys i want to know the exact  Difference between Error And Exception.
commented by Shrikant
error is the ir-recoverable such as out of memory error.
Exception is the run time recoverable error.
commented by Sohan Argulwar
In simple language error is which nobody can control of guess while exception can be guessed an handled (using try catch block)

8 Answers

+3 votes
answered by anonymous
An Error you can't recover from, where as an Exception can be caught and handled.
+3 votes
answered by Muhamad Nizar Iqbal
Error is the real something happen from exception. Exception is the way to catch the error. For example when you get the varianble let say String str, we got Null Pointer. The error is because our variable has NULL value and it catch with Exception: "Null Pointer Exception".
+3 votes
answered by Boyd Smith (200 points)

From the documentation: "An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch." "The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch."

You *usually* shouldn't do *anything* with Error or any subclass.  But, in particular, if you are writing a catch clause and it names Error or a subclass, you are writing an "unreassonable" application.

commented by monika (2,040 points)
good job @Boyd Smit , I agree with your point. thanks for the information.
+3 votes
answered by amit_pammu Expert (5,030 points)

Programming errors fall into three categories:
1-compilation errors,
2-run-time errors,
3-logical error

Compilation Errors

Compilation errors, also known as compiler errors, are errors that prevent your program from running

Logic Errors

Logic errors are errors that prevent your program from doing what you intended it to do..

Run Time Errors

Run-time errors are errors that occur while your program runs..

and exception are the run time error!

+1 vote
answered by nitu (1,680 points)
In simple words error can not be handled , but exceptions can be handled, with the help of try and catch
Conditions here...
}catch(Throwable ex){
ex.print trace();

Like this you can catch an exception.
0 votes
answered by Gabriel Pulido
I think an error is when something wrong happens, and and error prompt shows, while an Exception is an internal failure that can lead to an error or be caught and continue on.
0 votes
answered by Himanshu Jain
An Error "indicates serious problems that a reasonable application should not try to catch." while An Exception "indicates conditions that a reasonable application might want to catch."
0 votes
answered by Deepak Deshpande

Both Error and Exception are derived from java.lang.Throwable. Errors are those situations that cannot be handled by the JVM and your application cannot potentially recover from Errors.For example, you may run out of system resources, OutOfMemoryError etc. On the other hand exceptions are conditions that occur during the runtime of the application and your (JVM can recover from these conditions and your application can run normally.. For example, ClassCastException, OutOfBoundException, ArithmeticException, IOException.Exceptions are further classified into checked and unchecked exceptions. Please refer to the javadocs for details.

Related Questions

+7 votes
1 answer 564 views
+6 votes
1 answer 399 views
+2 votes
1 answer 139 views

Not a Member yet?

Ask to Folks Login

My Account
339 Folks are online
2 members and 337 guest online
Your feedback is highly appreciated