the following code snippet book oca/ocp java se 7 programmer 1 & 2 study guide kathy sierra , bert bates.
public void rethrow() throws sqlexception, ioexception { try { couldthrowanexception(); } catch (exception e) { // watch out: isn't // catching exception sublclasses log(e); throw e; // note: won't compile in java 6 } }
the text on page 393 states "you may have noticed couldthrowanexception() doesnt throw exception. compiler doesn't know this. method signature key compiler. can't assume no exception gets thrown, subclass override method , throw exception."
wouldn't incorrect or @ least misleading cause subclass cannot declare new or broader checked exceptions. or missing something?
if author referring unchecked exceptions here? compiler not care unchecked exceptions 1 way or other. missing point being made here. please me understand. thanks.
Comments
Post a Comment