Professional Documents
Culture Documents
-Generally under every program we will be comming across errors which are of 2
types:
-Compile Time Errors
-Run Time Errors
-A compile time error occurs due to the syntactical mistake that occurs in a
program, these are not considered to be dangerous.
-A runtime error also known as an Exception occurs under a program while the
execution of the program is taking place this can be due to various reasons like
wrong implementation of logic, invalid input supplied to the program etc., these
errors are considered to be dangerous because when they occur under the program the
program terminates abnormally with out executing the next lines of code.
-How can we stop the abnormal termination that occurs when an exception occurs ?
Ans: To stop the abnormal termination that occurs when an exception occurs we are
provided with an approach known as "Exception Handling", which allows u to stop the
abnormal termination as well as can be used to display user friendly error msgs to
the end users.
try
{
-Stmts which will cause the exception
-Stmts which are related with the exception and should not execute when
exception occurs
}
catch (<exception> <var>)
{
-Stmts which should execute only when the exception occurs
}
-----<multiple catch blocks>.....