Exception Handling in Java | Core Java Concepts Tutorials
This Core Java Concepts Tutorials”Exception Handling in Java” is providing introduction to exception handling including compile time errors, logical errors and runtime errors in java application.
- During program Compilation and Execution there is a chance to get 3 kinds of Errors
Compile time errors:
- Every language is having syntactical rules.
- While defining instruction set, we must follow these rules.
- Violation of syntax rules gives compile time errors.
- for example..
- Every method should have return type
- ‘this’ cannot be used in static context
- abstract & final cannot be combined
- Logical error is the not compiler error and run time error.
- It produces unexpected output when we run the application.
Logical Error Program
public static void main(String args)
int a=5 , b=2 ;
float c = a/b;
System.out.println("Result : "+c);
int / int --> int
int / float
float / int
float / float
- Violation of JVM rules.
- Runtime error is called Exception.
- As a programmer, we need to analyze the errors which will occur while application is running.
- As a programmer we can write the logic but that executes only in case of Exception at runtime.
- Abnormal termination of program.
- Informal information to End user.
- Improper shutdown of Resources.