Posts

Showing posts with the label Exception handling in java

Exception handling in Java

  Exception : Exceptions are exceptional/unusual/abnormal events that occur during the execution of programs.  An abnormal condition that disrupts Normal program flow. Exception handling : Exception Handling is a mechanism to handle runtime error. Exception Handling is mainly used to handle the checked exceptions.  If there occurs any unchecked exception such as NullPointerException, it is programmers fault that he is not performing check up before the code being used. How the exceptions are handled. Explain exception handling mechanism? Exceptions in java are handled using try, catch and finally blocks. try block :  The code or set of statements which are to be monitored for exception are kept in this block. Java try block is used to enclose the code that might throw an exception. It must be used within the method. The code that can cause exception is placed within try block. Java try block must be followed by either catch or finally block. catch block :...