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 :)

  1. what classes (and subclasses) examples of unchecked exceptions?

    answer: ioexceptions, classnotfoundexception, runtimeexception (its subclasses: arithmeticexception, nullpointerexception, indexoutofboundsexception, illegalargumentexception

  2. what 2 different ways programmer can deal checked exceptions avoid compil

    answer: use either try-catch block or declare exception in method header beforehand.

  3. 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.

  4. 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

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -