Exceptions: Basic Types Checked Unchecked Exceptions Run Time Error
Exceptions: Basic Types Checked Unchecked Exceptions Run Time Error
Checked Exceptions
. These are exceptional conditions which normally are due to user o a pro!ram because o a wron! input or operation "or example #supposin! user !i$es a ile name which does not exist. These exception are sub%ect to catch or speci y re&uirement. 'hich means either these should be included in try (catch or intently thrown
Unchecked Exceptions
These are o two types a) Run time b) Error These are not sub%ect to catch or speci y re&uirement Run time # These can normally be a$oided by a pro!rammer these may be caused by lo!ical error in pro!ram or some un unexpected run time error which has not been $isuali)ed by pro!rammer . These may be included in try catch * %a$a exception handlers can help to reco$er rom these type o exceptions.
Unchecked Exceptions
Errors # These are not in control o pro!rammer or example a ile cannot be opened because o some hardware problem
try + (( CODE WHICH MAY CAYSE EXCEPTIONS , catch -"ile.ot"oundException e) + /01E 1E//23E 0R 2CT40. , catch -40Exception e) + /01E 1E//23E 0R 2CT40., inally + some action or messa!e,
Checked exceptions
"or code which anticipate that a checked exception may occur must be contained in try catch "or example br.readline-)5 4 you purposely want to a$oid try and cache or checked exception use key word throws
static /trin! read"irst6ine"rom"ile-/trin! path) throws 40Exception + Code without try an catch