if try is followed by finally block what happen to exception
occured in try block
Answers were Sorted based on User's Feedback
Answer / yogita
Finally block wil anyways gets executed bcoz it meant to be
executed even the error occurs.
And, error wil also occur since purpose of catch block is
to handle the exception occured in try block and present it
to user in a user friendly manner. If error has not been
handled in catch block, it will stil show the system error
msg(not the user understandable messgae what we generally
do)
Is This Answer Correct ? | 11 Yes | 1 No |
Answer / 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 |
. With the help of above table EMP, perform the following operation is sql. a) Add the new column “DEPTNO” b) Rename the table c) Update table d) Modify the table if column ‘SAL’ whose data type is number (10) and you want to enter varchar2 (15) . For example $USD 20 etc.
what are the top level class of interface in java?
how to generate dsnless connectivity in j2ee
About CLR, reflection and assemblies?
iam confused among testing ,.net and java. can anybody help me.
How to connect the .accdb database file of microsoft access to the Visual Basic 6.0 forms?
what is web configuration file
is it acceptable if we declare multiple exceptions in same overridden method.
In OB52 , How to define two open posting period, Like only 5 and 8 posting should be open.. should not open 6 and 7..period..
Programs in JAVA to get the remainder and quotient of given two numbers without using % and / operators?
Even if all fields are initialized also in a program, I am getting COBOL/400 decimal data error .why is it coming?
how can i split string in a textbox in windows appication using C#.net