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
What is the meaning of client-server application. The purpose of Client-Server Application. with description.
what is the software to run the GSM gate opener program
How to print No.of.rows affected after updation using ADO.Net
what is the diff bw sql direct and jdbc update can't we do select and updating operation in sql direct
Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming
Hey this is venkatesh.Please can any body tell me what is SFLNXTCHG?where we use this keyword?what perpuse we use this?Can you tell me in real time senario with example? And in 7 specification(RPG/400)what is the mandatory specification using programs?
Write a program to swap the content of two variables without using a third variable.
Where do we need Operator overloading?
what is delimiter in sas ?
what is difference between kpo and it industry? that is in terms of work, package etc
What is test execution and when will we start execution please send me one example for this question
what is dot net framework
What is Negative testing?
How to connect to ms word wit VB ojective is to prepare s/w to generate question paper , selects questions randomly from the ms access , database
what is the difference between uservariables and systemvariables (in Environmental variables)???