Easy learning with example program codes

how the exceptions are handled in java?

Exception handling is a mechanism to handle runtime errors, so that normal flow of the program can be maintained.

How to write an exception handler?

To write a simple exception handler, first enclose the code that might throw an exception within try block. When an exception occurs in try block, it will be handled by an appropriate exception handler. Exception handler can associate with try block by using catch block or finally block after it.

Note: catch and finally block both can be attached with single try block. Hierarchy should be try-catch-finally.

Java interview questions on exception handling

Please follow and like us:

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki