Quality Testing

Quality is delighting customers

Any one tell me exact difference between Exception and Error? Thanks in advance

Views: 77

Reply to This

Replies to This Discussion

Hi Usha,

Exceptions are those which can be handled at the run time where as errors cannot be handled.
Examples for exceptions: Array out of bonds, attempt to divide by zero etc.
Exceptions can be handled by handlers using try - catch.

Gowtham, thanks for your quick reply...
UR welcome Usha
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.
Error : Which causes risk in the project
Exception: An error which can/cannot be caught, which may or may not cause to continue.

Error leads to an Exception.

Error is an expected situation in an application. For example, think of a situation where you encounter a divided by zero or NaN in your logic, and the system would throw an error and stop. So you need to handle this situation wherever you logic expects that.

Where as exception is a runtime error that the program might encounter during the execution of the program. For example you are trying to populate a table where the connection is closed, or you are trying to write a file, where hard disk is full. These are exceptions which are unpredictable errors during runtime.
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
Hi Kusuma,

Does JVM has memory? if yes, what is that memory called as?

If error is unrecoverable, what to do? Why OutOfMemoryError can't be named as a error instead Exception???

Expecting reply!

Error : Something goes wrong in our application/program, that leads to crash your output/logic is called as error. The the error may be of syntatic error or error which can easily identify the programmer.

Exception : During the execution(runtime) of our application/program, the system leads to something wrong statements like 'system out of memory' 'out of arguments' called Exception.


TTWT Magazine





© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service