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

how to study PHP my own? i reffered many sites.. but as being a fresher i couldnt follow those... which site will be the best one?

1850


what are the 3 forms of a prolog term

2757


what is the certificates in biztalk?

1433


iam confused among testing ,.net and java. can anybody help me.

1578


EXPLAIN UNARY OPEARATORS

1807






details description on this mantis? who is founder of this mantis?

1687


In mainframe SDSF, Can we copy the list of jobs currently executing in SDSF in to a seperate DATASET...?

1851


how do you generate source code for the automatic generation for receipt number

3833


how can we implement locks in plsql?

1797


how many types of bytes are there???

1991


what is difference between object oriented programming structure and object oriented programming system?

1448


when will triggars the at new event in abap and web dybn pro?

1494


what is web service in java? have u use before.

1637


I m new to the dbms. Recently i came across words clustered indexes & nonclustered indexes but i dont know what is this all about & whats the difference between them.. So please help me!!!!!!!!

1539


I want to insert date in the form of yyyy-mm-dd... if any changes happen while inserting date format want to show error meg...any one can solve this..??

1663