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

Define distributed queries. can you explain me as soon as possible

1626


how to get second highest salary from a employee table and how get a 5th highest salary from a employee table by using proc sql?

1893


how to stop execution of step 3 in a job mainframe

1711


can any method return type may be constructor , or that method name allow

1582


Find out the roles which gives access to all tables in SAP? Thanks in advance.

1563






give idea for creating screen in abap

1645


what is throws keyword

2990


what is programmable BIST in today ic design

1649


What is BASIS

1665


what are the topics choosen for jam round for interviews

1162


I am taking the bmc control m/enterprise manager 7.0 scheduling test and just wanted to see what kind of questions they would ask or if anyone has taken the test and how long it is for how many questions?

5667


any drawback are there in mantis?

1642


What are the Short cut Keys of Tally ERP?

1773


what is the purpose of checked Menu options

1986


Hi can you please send me recent(present) interview questions and technical qyestions with answers for "BUSSIESS OBJECTS" and "DATA WAREHOUSE".pls its urgent for me my mail id is sekhar.cs82@gmail.com,manjuforgis@gmail.com. thanks in advance

1489