1.

Exception vs Error in Java

Answer»

Errors in Java are a part of the java.lang.error CLASS. Exceptions in Java a part of the java.lang.Exception class. Both are a part of the java.lang.Throwable class.

Basis
Errors
Exceptions
Type
Errors in Java are of the UNCHECKED type.
Exceptions in Java are both of the checked and unchecked type.
Occurrence
Errors occur at the run TIME and are oblivious to knowledge of the compiler.
Exceptions also occur at run time but checked exceptions are known to the compiler.
Class
They’re defined in java.lang.Error class
They’re a part of the java.lang.Exception class
Dependency
They are caused by the environment in which the compiler is run.
The program is solely responsible for GENERATION of exceptions.
Recovery
Recovery from an error is impossible.
Recovery from exceptions is possible through try-catch blocks.


Discussion

No Comment Found