if try is followed by finally block what happen to exception
occured in try block
Answers were Sorted based on User's Feedback
Answer / yogita
Finally block wil anyways gets executed bcoz it meant to be
executed even the error occurs.
And, error wil also occur since purpose of catch block is
to handle the exception occured in try block and present it
to user in a user friendly manner. If error has not been
handled in catch block, it will stil show the system error
msg(not the user understandable messgae what we generally
do)
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / solanki_mca
well, in this case you have not written any code to handle
Exception so u will get exception in the form of error.
Because if any exception occurs in try block control(run
time environment) searches for its corresponding catch
block, and if it will not found any it will raise the error
and control willl not be able to reach inside finally block
so code written inside will not be executed.
class abc
{
public static void Main(String[] args)
{
try
{
// some code here which cause erorr.
}
finally
{
// control will not come inside
// code to clean up system resources.
}
}
Even if u write catch block which does not belongs to
particular exception that has occured, in this case also
you will get error.
So if you are not sure about kind of exception that could
be occured; implement catch block which catches any kind of
exception as below.
class abc
{
try
{
// some code that will raise ArrayIndexOutOfBound xception
}
catch(ArithmeticException ex1)
{
// some code
}
catch(Exception err)
{
// code that will be handle to any kind of exception
}
finally
{
// clean up code
}
}
Regards,
Hitesh
| Is This Answer Correct ? | 7 Yes | 4 No |
Tips for blog integration by www.esteemwebsolutions.com. Can Any body suggest me to how to make wonderful questions on web integration..
___ method used to move a recordset pointer in nth position in DAG.
< DL Compact > tag is used for
Write a pascal program to calculate the sum of the first 100 even number and odd number
In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking?
can we allocate memory for interface? if no then why?
how CLR identify vb file?
What is the first message line that any language learning prints on the screen? and why?
Code for display the images from drive using vb 6.0?
What are the Advantages of HashMap over Vector?
I want Ada programming language books. Could anyone post me any link for that?
What is Partial class and its use?