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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -