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 many packages available in java??
Write a program to calculate the following i want a Java program for this condition 1+4+9+16+….+100 Like this (1^2+2^2) Hint use function pow(a,b)
What do you mean by an array ? explain with an example
iam confused among testing ,.net and java. can anybody help me.
What is %Type,%Rowtype?
Given a set. Write the pseudo code to get all the subsets for the given set. Eg. Input : {1,2} Output : (),(1),(2),(1,2)
in network security,how we identified threat?some one say we found threat according to it's signature,but how we get signature or pattern of the virus?
is it possible to learn sap from book without any tutorial. if yes please mention the beginner,s book of sap and also make your valuable advice for self study of sap .
how to work search engine? plz detail answer me.
Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren?t present.
How to update a data for the views in the relational data base schema
what diffrence between procedure and function?