the exceptions / don' have to try or catch /which goshopping(might throw because /getreadyforclass(will just pass these along makecookiesforta() function can declare that it throws as many exceptions as it likes such listing can be simplified somewhat if all exceptions that can be thrown are subclasses of the same exception in this casewe only have to declare that method throws the appropriate superclass kinds of throwables java defines classes exception and error as subclasses of throwablewhich denotes any object that can be thrown and caught alsoit defines class runtimeexception as subclass of exception the error class is used for abnormal conditions occurring in the run-time environmentsuch as running out of memory errors can be caughtbut they probably should not bebecause they usually signal problems that cannot be handled gracefully an error message or sudden program termination is about as much grace as we can expect the exception class is the root of the exception hierarchy specialized exceptions (for exampleboundaryviolationexceptionshould be defined by subclassing from either exception or runtimeexception note that exceptions that are not subclasses of runtimeexception must be declared in the throws clause of any method that can throw them catching exceptions when an exception is thrownit must be caught or the program will terminate in any particular methodan exception in that method can be passed through to the calling method or it can be caught in that method when an exception is caughtit can be analyzed and dealt with the general methodology for dealing with exceptions is to "tryto execute some fragment of code that might throw an exception if it does throw an exceptionthen that exception is caught by having the flow of control jump to predefined catch block that contains the code dealing with the exception the general syntax for try-catch block in java is as follows