if try is followed by finally block what happen to exception
occured in try block
Answer Posted / 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 |
Post New Answer View All Answers
How can we develop a multi-tier application in Java?
1.Mutating table
What is the use of sas software? Is sas and sap are different?
How to merge Action Form with Dyna Action Form in Struts.
Write a program to create a process in UNIX
Difference between debugging, running, executing of an application
What is the difference between WebIntelligence and Designer in creating universes?
< DL Compact > tag is used for
Difference between HTML and DHTML?
What is the difference between DECISION COVERAGE(DC) and MODIFIED CONDITION/DECISION COVERAGE(MCDC)?
Can any one give an example (Source Code) on virtual function implemetation in Java?
how to generate dsnless connectivity in j2ee
Write a program to find factorial of a number using functions
I am looking for selenium RC online Training in chennai. can any one tell me the best institute
Plz sent me in .net 2.0 interview Question & answers?