A. An exception is thrown and the exception message thrown from first catch is diplayed with the exception stack trace. B. An exception is thrown and the exception message thrown from second catch is diplayed with the exception stack trace. C. Prints nothing.
D. Compilation error.
E. Prints i=? where ? stands for the generated random value.
Surprisingly ...the answer is C
Error stack trace is not thrown because of finally I guess it should atleast throw exception...
Pls throw some insight if my understanding is wrong
In catch Block if any exceptions are raised again or it return call to the called method. Before handling the exception or before returning value it will execute finally block.
But in case finally block there is no control transfers like this. you returned value of type void. If you have any return statements or System.exit()in finally block,if any exception raising and return statements are present in catch block, then they were discarded.
Since the finally block of a try-catch-finally clause is always executed, even if a break or return statement is executed in the try block, the finally block can actually override the request to break or return.
The finally block can decide not to break or return or even change the return value by executing its own return statement.
here return statement in finally overrides return statemetn of catch block
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com