exceptions exceptions are unexpected events that occur during the execution of program an exception can be the result of an error condition or simply an unanticipated input in any casein an object-oriented languagesuch as javaexceptions can be thought of as being objects themselves throwing exceptions in javaexceptions are objects that are thrown by code that encounters some sort of unexpected condition they can also be thrown by the java run-time environment should it encounter an unexpected conditionlike running out of object memory thrown exception is caught by other code that "handlesthe exception somehowor the program is terminated unexpectedly (we will say more about catching exceptions shortly exceptions originate when piece of java code finds some sort of problem during execution and throws an exception object it is convenient to give descriptive name to the class of the exception object for instanceif we try to delete the tenth element from sequence that has only five elementsthe code may throw boundaryviolationexception this action could be donefor exampleusing the following code fragmentif (insertindex > lengththrow new boundaryviolationexception("no element at index insertindex)