+7 votes
8.9k views
in Programming by (990 points)
edited by
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.
0
by
error is the ir-recoverable such as out of memory error.
Exception is the run time recoverable error.
0
by
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
by
An Error you can't recover from, where as an Exception can be caught and handled.
+3 votes
by
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
by (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.

0
by (2.8k points)
good job @Boyd Smit , I agree with your point. thanks for the information.
+3 votes
by Expert (5.1k 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
by (1.7k points)
In simple words error can not be handled , but exceptions can be handled, with the help of try and catch
try{
Conditions here...
}catch(Throwable ex){
ex.print trace();
}

Like this you can catch an exception.
0 votes
by
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
by
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
by

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.

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated