
Exception Handling in Java
What is Exception ? An exception is an unexpected event that occurs during program execution that affects the flow of the program. What is Exception Handling? Exception handling is a mechanism to handle runtime errors. So the program does NOT crash unexpectedly. It prevents the program from stopping suddenly. What are the types of Exception? Checked Exception also called compile-time exception. Unchecked Exception also called runtime exception. What is Checked Exception? Exceptions that occur at compile time. Compiler forces you to handle it at compile time. Example: IOException SQLException FileNotFoundException ClassNotFoundException What is Unchecked Exception? Exceptions that occur at runtime. No Comuplsion to handle it. Example: ArithmeticException InputMismatchException NullPointerException List the keywrods used in exception handling: try catch finally throw throws try catch Example: The try block contains code that might throw an exception, while the catch block defines how to
Continue reading on Dev.to Tutorial
Opens in a new tab



