WHO TO TRY AND CATCH, FINALLY EXECUTE

Who to try and catch, finally execute


  • Normal execution only try block is executed and all catch block skip.

  • Abnormal condition is executed than convert normal condition than remaining catch statement is not use.

  • One catch can handled only the abnormal condition.

  • One catch handled only one abnormal condition .

  • javapadho
    Flow of who to try and catch, finally execute

    javapadho
    Who to try and catch, finally execute

    • If in try not return but in catch return present finally return present than this is compile successfully.

    • If every return statement present is try, catch, finally and return statement present after finally than compiler give unreachable code.

    • Finally block is executed if exception caught or not, return statement present or not .if exception occur in catch statement or not but finally is execute.

    • Nested try, catch, finally all possible.
      In try -> possible to put try, catch, finally
      In catch -> possible to put try, catch, finally
      In finally -> possible to put try, catch, finally