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 |
How to get the index of the clicked field in reports in ABAP?
1.What is difference between symget and & in sas? 2.what is difference between callsymput and %let?
what is the diff bw sql direct and jdbc update can't we do select and updating operation in sql direct
Please describe an example where you used object orientation in one of your programs.
3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....
Hello all, My name is Nrupali, am a fresher, i know C language beginner. dont have any experience. planning to learn Php. let me know which language should i choose to learn or for salary purpose and growth??? kindly help me to take decision. thanks
Programs in JAVA to get the remainder and quotient of given two numbers without using % and / operators?
5. How do you round the addition or subtraction of two numbers in assembler?
What is the best action a system can take when deadlock is detected
hi i m deepak my shedule for NIC pi is 17 Apr please contact me if anybody has interview on same day or give me some idea who have faced
A combination of multiple keys defined in a physical file or logical file is called a _________ key
In Java what is the difference between following two statements ? int a[],b; int []a,b;