Exception Handling:
Error conditions which are not expected to occur under normal conditions are known as exceptions. Whenever an exception occurs, bad things happen. For instance, a negative number is passed to a function which computes the square root of a number. The method expects all numbers it receives to be positive real numbers. It receives a negative number alter, and an exception occurs. Several times programs die right then and there; other times they do more insidious things, like as passing wrong pointers which eventually access protected areas of the system.
While there is no definitive way to handle exceptions in C++ language, any bleary-eyed C++ programmers will be happy to know that exceptions are a fundamental category of the Java programming language. Within Java if you call a method which could throw an exception, you have check to see if any of the possible exceptions occurred and handle them. Further, the Java compiler checks for exception handling and will tell you if you have not handled the exceptions to a particular method.
There are problem which are beyond program control, and thus also beyond the programmer's control. These involve problems like as running out of memory. Other nonprogrammatic problems are the network being down or a hardware failure.
There are two major classes of problems in java: exceptions and errors. Errors are caused via problems in java itself and are commonly of too detailed a nature for the program itself to solve. Whenever an error is encountered, java produce an error message to the screen and aborts the program.