Exceptions in java
Exceptions in java
Intro
Types of errors:
1. Syntax: if you write the keyword name incorrect it will throw error this is syntax errors.
2. Runtime: these are crucial they occur during the execution of code and user accessing.
3. Logical: these can be verified during compile time.
This is a critical statement it will give us error and we need to handle these errors
So what programming standard states that you have to write normal statements normally
and critical statements should be enclosed in try block , if try block throws error , you have to
catch the error
For particular statements you can apply try catch and for whole class we need to extend it by
exception class
exception classes hierarchy
Exceptions we can handle , but error s like jvm not working properly we cannot handle it
We should keep exception only at last because if we mention them in first place , it will
handles all the exceptions and what is the use of other two exception classes
finally block is printed in all the scenarios
If we know our program doesn’t throw any exception, then will not use try, catch and we will
throw exception class
you can mention many but this will not handle error but only suppress it
Throws should be only after method if