Exercise 17.x1: For each of the following two Java statements, indicate whether it is legal, and if so, explain under what circumstances each exception handler would execute. The first version is
try { System.in.read(); } catch(java.io.CharConversionException e2){ System.err.println("Caught a CharConversionException."); } catch(java.io.IOException e1){ System.err.println("Caught an IOException."); }
and the second version is
try { System.in.read(); } catch(java.io.IOException e1){ System.err.println("Caught an IOException."); } catch(java.io.CharConversionException e2){ System.err.println("Caught a CharConversionException."); }
Do exercise 18.6 on page 381.