java - Double checking exception and try-catch logic -
so started unit , answered couple questions outta book. answers show proper understanding of exceptions , try-catch blocks? wanted verify before start working try-catch blocks/exceptions :)
what classes (and subclasses) examples of unchecked exceptions?
answer: ioexceptions, classnotfoundexception, runtimeexception (its subclasses: arithmeticexception, nullpointerexception, indexoutofboundsexception, illegalargumentexception
what 2 different ways programmer can deal checked exceptions avoid compil
answer: use either try-catch block or declare exception in method header beforehand.
describe steps occur when exception not caught in current method
answer: if exception not caught in current method, java exits method, passes exception method invoke method, , continues same process find handler. if no handler found in chain of methods being invoked, program terminates , prints error message on console. (ths process of finding ‘handler’ called catching , exception.
how ‘chained exception’ different exception has been rethrown?
answer: rethrown exception occurs when handler cannot process exception or wants let caller notified of exception. chained exception when throw exception along exception. syntax rethrowing exception: throw ex(ex = object reference) syntax chained exception: throw new exception(“message…”, ex);
ioexception , classnotfoundexception checked exceptions. runtimeexception , derived classes unchecked.
Comments
Post a Comment