/* related posts with thumb nails */

Exceptions and Exception Handling & its advantages:

Exception: Exception is a condition caused by a runtime error in a program. It is an abnormal event that arises during the execution of the program and terminates the normal flow of the program. Abnormality occurs when the program is running. For example, if a user enters a string where an integer is expected, an error occurs at runtime that causes the program to be stopped intermediately. Java has a built-in mechanism for handling runtime errors, referred to as exception handling. This is to ensure that we can write robust (error-free) programs.

Exception Handling: Handling runtime errors is exception handling. In java, when an abnormal condition occurs within a method then the exceptions are thrown in form of Exception Object i.e. the normal program control flow is stopped and an exception object is created to handle that exceptional condition. If the exception object is not caught and handled properly, the interpreter will display an error message and it will terminate the program. If we want the program to continue with the execution of the remaining code, then we should try to catch the exception.

Advantages of Exception-handling in Java:

· It ensures safer termination of a program.

· It demands proper input entry or proper handling of a program.

· User has a chance to correct the accidental mistakes while running a program.

· The program becomes robust and more user-friendly.

· With this mechanism the working code and the error-handling code can be disintegrated.

· It allows different handling code-blocks for different types of errors.

Related Topics:

0 comments:

Post a Comment