Ad Code

Responsive Advertisement

Exception and Exception Error

Exception and Exception Error

Program may come across two different types of error in it.
  1. Compile-Time Error.
  2. Run-Time Error. 
An error which comes into picture at the time of compilation of the program is a compile time error. This error may come due to syntactical mistakes and moreover these are not dangerous.
An error which comes into picture while execution of a program is going on is referred as a run-time error, which may come into picture due to various reason like-
  • Wrong implementation of logic.
  • Wrong input supply to program.
  • Missing of required resources of an application etc.
These errors are what we call as Exception also.
Whenever a run-time error or exception occurs with a program, the program terminate abnormally without executing the next line of code in the program, even if  that code is no way related with the error occurred and also displayed an error massage telling the reason for abnormal termination.

- As a programmer an exception is a class which is responsible in abnormal termination of the program. Within a program we may be coming across various types of runtimes error, mating with the scenario we have been provided with a separate exception class for each runtime error.
  • FormatException
  • DivideByZeroException
  • IndexOutOfRangeException
  • NullReferanceException
  • SqlException etc. 

- These exception classes are predefined under the system Namespace and each class is responsible for abnormal termination as well as displaying of an error massage related with the error.

- Implementation of Exception classes has been done as following:

Exception Handling

As we discussed whenever an exception comes into picture the program terminate abnormally without executing the next lines of code even if the code is no way related with the exception, so if we want to stop the abnormal termination of program and still execute the code which is not related with the exception being occurred we need the make use of exception handballing.


- To handle an exception we must enclosed the code under some spatial block known as try-Catch blocks. 
Reactions

Post a Comment

0 Comments