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


Please Help Members By Posting Answers For Below Questions

What is the meaning of client-server application. The purpose of Client-Server Application. with description.

1643


what is the software to run the GSM gate opener program

1647


How to print No.of.rows affected after updation using ADO.Net

2470


what is the diff bw sql direct and jdbc update can't we do select and updating operation in sql direct

1674


Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming

11113






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?

1515


Write a program to swap the content of two variables without using a third variable.

567


Where do we need Operator overloading?

643


what is delimiter in sas ?

1537


what is difference between kpo and it industry? that is in terms of work, package etc

1530


What is test execution and when will we start execution please send me one example for this question

1419


what is dot net framework

2330


What is Negative testing?

1492


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

2002


what is the difference between uservariables and systemvariables (in Environmental variables)???

1931