Computer Science, asked by Aishn7abaJOSS, 1 year ago

difference between error and exception

Answers

Answered by amruthadeshpande
2

1) Recovering from Error is not possible. The only solution to errors is to terminate the execution. Where as you can recover from Exception by using either try-catch blocks or throwing exception back to caller.

2) You will not be able to handle the Errors using try-catch blocks. Even if you handle them using try-catch blocks, your application will not recover if they happen. On the other hand, Exceptions can be handled using try-catch blocks and can make program flow normal if they happen.

3) Exceptions in java are divided into two categories – checked and unchecked. Where as all Errors belongs to only one category i.e unchecked.

4) Compiler will not have any knowledge about unchecked exceptions which include Errors and sub classes of Run Time Exception because they happen at run time. Where as compiler will have knowledge about checked Exceptions. Compiler will force you to keep try-catch blocks if it sees any statements which may throw checked exceptions.

5) Exceptions are related to application where as Errors are related to environment in which application is running.


amruthadeshpande: plss mark it as brainliest...
Answered by PJPOOJA
1
Exception and error exceptions are those which can be handled at the run time whereas errors cannot be handled.An exception is an Object of a type deriving from the System.Exception class. system exception is thrown by the CLR (Common Language Runtime) when errors occur that are nonfatal and recoverable by user programs. It is meant to give you an opportunity to do something with throw statement to transfer control to a catch clause in a try block.

An Error is something that most of the time you cannot handle it. Errors are unchecked exception and the developer is not required to do anything with these. Errors normally tend to signal the end of your program, it typically cannot be recovered from and should cause you exit from current program. It should not be caught or handled.All the Errors are Exceptions but the reverse is not true. In general Errors are which nobody can control or guess when it happened, on the other hand Exception can be guessed and can be handled.
Similar questions