1
Answer

exception handling

Photo of Amit Kr

Amit Kr

12y
953
1
If we write some code after Finally block then how that code will execute and in which conditions?

(It was asked in my interview today)

Answers (1)

0
Sukesh Marla
NA 11.8k 1.2m 12y
If you write something after finally block,Then it wont execute if
  1. Catch part throw some exception which is not handled by another try catch,
  2. Finally part throw some exception which is not handled by another try catch,
  3. Code  written before Try throw some exception which is not handled by another try catch,
  4. return statement is executed prior to the statement written after Finally...
    (Means return statement written inside Try/Catch/Code Block before Try, and it executes)
    (Writing return inside finally causes syntax error so obviously it doesn't matter).


Hope it helped.
Mark as answer if it is. :)