we know that exception can happen ..but we dont know about errors .. we dont have knowledge about them in already ...but in case of exception we take some prevential actions and put already an exception block to catch that exception
Exception handling is the means by which exceptions -- anomalous events -- are resolved without causing a runtime error.
separating error handling code from 'regular' code
Exception handling, also known as error handling, is a process that involves creating "exception handlers" to deal with many problems that can occur with a PHP script. This code will "catch" the error, and deal with it in some fashion other than crashing and ending the script. This allows programmers to deal with such issues without causing their website to go down or cause other problems.
sometimes there are situations where the program is vary long which can make error debugging a long process so java provides a facility to make user defined exception handling suppose we are dividing two numbers a/b and if the user enters the value of b 0, the user wants to display an error of your own so the user can do this by using exception handling
Exceptions are the error handling mechanism of C#. When an error occurs, an exception is thrown using this syntax: void BadMethod() { bool Error = true; if (Error) { throw new Exception("Whoops!"); } } Methods can then handle exceptions using a try/catch/finally syntax. The code that you are trying to execute goes between a try { } block, the code to handle the error goes between the catch { } block. Any code that you put between the finally { } block will always execute after the exception handling code is complete (or if an error did not occur). void test() { try { BadMethod(); catch (Exception ex) { Console.WriteLine("An error occured. The description is: " + ex.Description); } finally { Console.WriteLine("I'm done!"); } }
Exception handling helps us catch or identify abnormal scenarios in our code and handle them appropriately instead of throwing up a random error on the front-end (User Interface) of the application. Exception handling allows developers to detect errors easily without writing special code to test return values. Even better, it lets us keep exception-handling code cleanly separated from the exception-generating code. It also lets us use the same exception-handling code to deal with a range of possible exceptions.
Easy: there is no exception-handling in C.
Exception handling helps us catch or identify abnormal scenarios in our code and handle them appropriately instead of throwing up a random error on the front-end (User Interface) of the application. Exception handling allows developers to detect errors easily without writing special code to test return values. Even better, it lets us keep exception-handling code cleanly separated from the exception-generating code. It also lets us use the same exception-handling code to deal with a range of possible exceptions
An exception is abnormal program flow, so handling the exception is the very definition of resolving the abnormality.
interrupt handling is the process of handling a break or interrupt called by a program where as exception handling is for handling some exceptional conditions that'll occur when a program is running
Error: Any departure from the expected behavior of the system or program, which stops the working of the system is an error. Exception:Any error or problem which one can handle and continue to work normally. Note that in Java a compile time error is normally called an "error," while a runtime error is called an "exception." Errors don't have subclasses while exception has two subclasses, they are compile time exception or checked exception (ClassNotFound Exception, IOException, SQLException etc.) and runtime or unchecked exception(ArrayIndexOutOfBounds Exception, NumberFormat Exception).
Exception handling is necessary for string handling as there might be some unexpected situation during string handling which may lead to program crash or abrupt termination