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
Difference of Console, web & windows applications?
can any method return type may be constructor , or that method name allow
how to remove header and footer in jcl using sort utility
Difference between views and index in sas programming
shall we execute our java programmes in jre
how many types of bytes are there???
Please forward important interview and basic questions in VB6 on my email id: usneha_16@yahoo.co.in
When we use Windows authentication mode
what is the difference between an OS(operating system) and Framework?
hi viewers, tell me,what is scripting and programming, define and difference...pls
You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?
could u please also write an example of a code that involves instances from an abstract class just as u did for interfaces because u said it could also work which i really doubt. thanks
Hi all... I had completed MSC(Computer) and had join the construction company based on sap.they want me to work on abap.but software company is totally different from construction company and they want me 2 grasp it as fast i can.i am finding it difficult.what should i do??????
How to set on/off a group of indicators in a single statement?
Definition of Singleton Class? what is the Purpose of it? what is the advantage?