What is the difference between exception and error


Answered by Scott on 2005-05-12 09:50:36: An Exception can be caught and recovered: ArrayIndexOutOfBoundsException means you tried to access a position of an Array that does not exist - no big deal. 
 
An Error is unrecoverable: OutOfMemoryError means that the JVM has no more memory to contin

Showing Answers 1 - 11 of 11 Answers

Scott

  • May 12th, 2005
 

An Exception can be caught and recovered: ArrayIndexOutOfBoundsException means you tried to access a position of an Array that does not exist - no big deal. 
 
An Error is unrecoverable: OutOfMemoryError means that the JVM has no more memory to contin

  Was this answer useful?  Yes

syed abdul kather

  • Dec 15th, 2006
 

Thanks for your answer

  Was this answer useful?  Yes

hari

  • Dec 20th, 2006
 

exception will give user friendly message which is defined in exception handling,whereas error message is standard given by oracle.

  Was this answer useful?  Yes

In Java Exception and Error are sub class of Throwable.

It is differentiated based on the program control.  Error such as OutOfMemory Error which no programmer can guess and can handle it.  It depends on dynamically based on architectire, OS and server configuration.  Where as Exception programmer can handle it and can avoid application's misbehavior.

For example if your code is looking for a file which is not available then IOException is thrown.  Such instances programmer can guess and can handle it.

In general error is which nobody can control or guess when it occurs.  Exception can be guessed and can be handled.

  Was this answer useful?  Yes

derrickinit

  • Oct 31st, 2010
 

Error: Any departure from the expected behavior of the system or program, which stops the working of the system is an error. In general error is which nobody can control or guess when it occurs.

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

In Java Exception and Error are sub class of Throwable. It is differentiated based on the program control. Error such as OutOfMemoryError which no programmer can guess and can handle it. It depends on dynamically based on architectire, OS and server configuration. Where as Exception programmer can handle it and can avoid application's misbehavior. For example if your code is looking for a file which is not available then IOException is thrown.Such instances programmer can guess and can handle it.

Note that in Java a compile time error is normally called an "error," while a runtime error is called an "exception."

  Was this answer useful?  Yes

Bijal

  • Jul 21st, 2011
 

Exception:Exception can be handled.
Error:Error cannot be handled.
Exception:Exception do no terminate the program.
Error :Terminates the program

alin20_84

  • Feb 14th, 2012
 

also A method is not required to declare in its throws clause any subclasses of Error becuase this is an unchecked exception

  Was this answer useful?  Yes

vishnu

  • Feb 24th, 2012
 

The exception class defines mild error conditions that your program encounters. Exceptions can occur when trying to open the file, which does not exist, the network connection is disrupted, operands being manipulated are out of prescribed ranges, the class file you are interested in loading is missing. The error class defines serious error conditions that you should not attempt to recover from. In most cases it is advisable to let the program terminate when such an error is encountered.

  Was this answer useful?  Yes

sreerenjini s

  • May 18th, 2013
 

An exception is a condition that is caused by a run time error in the program .When the java interpreter encounters an error like division by zero,it creates an exception object and throws it.

  Was this answer useful?  Yes

sravani

  • Jun 3rd, 2013
 

Exception is nothing but error but some difference whenever exception will raise program can execute continuously where as error program will not execute

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions