There 5 exception handling keyword, which you will come across very frequently.
5 keyword in java exception handling
- try - Any exception occurring in try block is catched by catch block.
- catch - catch block is always followed by try block.
- finally finally block can can only exist if try or try-catch block is there, finally block can’t be used alone in java.
Features of finally >
- finally block is always executed irrespective of exception is thrown or not.
- finally is keyword in java.
- finally block is optional in java, we may use it or not.
finally block is not executed in following scenarios >
- finally is not executed when System.exit is called.
- if in case JVM crashes because of some java.util.Error.
- throw throw is a keyword in java.