java Exception handling fundamentals

A java Exception is an object that describes an exceptional condition that has occurred in a piece of code .when an exceptional condition arises,an object representing that exception is created and thrown  in the method that caused the error.that may to choose handle the exception itself,or pass it on.Either way at same point ,the exception is Caught and processed.Exceptions can be generated by the Java run time system,or they can be manually generated by your code.Exceptions thrown by java relate to fundamental errors that violate the rules of the java language or the constraints of the java execution environment .Manually generated exceptions are typically used to report some error condition to the caller of a method

Java exception handling is managed via five keywords try,catch,throw,throws and finally . Briefly ,here is how they work.Program statements that you want to monitor for exceptions are contained within a try  block ,it is thrown .Your code can catch this exceptions are automatically thrown by the java run time system .To manually throw an exception use the keyword throw.Any exception that  is thrown out if a method must be specified as such by throws clause.Any exception that thrown out of a method must be specified as such by a throws clause.Any code that absolutely must be executed before a method returns is put in a finally block.

java Exception handling fundamentals

 

learn java programming Copyright © 2011-2012 | Powered by appsackel.org