Exception is an abnormal flow in the execution of program which a method can't handle the execution itself . This situation is called as an exception .
Come to Java
There are two types of exceptions in java
Checked exceptions:
checked exceptions are also known as compile time exceptions as they are identified during compile time of the program.Exception and all the subclasses of Exception class are checked exceptions.
Example : FileNotFoundException .
Unchecked exceptions:
Unchecked Exceptions are also known as runtime exceptions as they are identified during the runtime of the program. class Runtime Exception and all the subclasses of Runtime Exception are unchecked Exceptions.
Examples : NullPointerException , ArrayIndexOutofBoundException.
Error :
Errors should never be created, thrown, caught, or repaired. They are usually beyond the scope of your application code such as 'out of memory'. Even if you caught an out of memory error, you wouldn't likely be in a better place than the system garbage collector to fix this (and you'd have to fix it while allocating no new memory) so its better to let the system crash and repair the root cause.
Errors are :
Are always unchecked
Usually indicate a system error or a problem with a low-level resource
Should be handled at the system level, if possible
No comments:
Post a Comment