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 |
Ordered List tag is
can u help me? how do solve the transpose problem in ireport? if any one know send to eswaran_2006@yahoo.co.in
write algo for cobol program whichuse three flat file to extract some specific information 8 marks mainframe
How can recruiter justified that the candidate is expert in Algorithm and datastructure for Software product development ?
5.Call by value and Call by reference with program?
Piggy backing is a technique for a) Flow control b) sequence c) Acknowledgement d) retransmition
17 Answers Fast Booking, HCL, Lucent, NIC,
What is Console Application? & The purpose Of Console Application? with description.
what is the main usage of an abstract keyword?please follow the program class A { void display() { System.out.println("hai"); } void print() { } } class B extends A { void print() { System.out.println("Hello"); } } In this program i was gives the implementation of print() according to my requirements in subclass.And there is no definition in superclass then why we can use abstract keyword before a method that i want to gives definition in other classes,is any mistakes in the above usage of method?
Delta 5 weight scale not connect with oracle application what i can do?
What do you mean by an array ? explain with an example
SAS question: I have 50 fils a1,a2,...,a50. the primary key is upc. then if i want to merge all 50 files, the code is as follows, data test; merge a1 ... a50; by upc; run; we know that writing all 50 files name is time consuming, is there any standard format of this code?
I HAVE DONE TESTING TOOLS COURSE,NOW I AM FRESHER,I AM NOT GETTING ANY CALLS,I WANT TO DO THE PROJECT ,WHERE I HAVE TO MEET TO DO THE PROJECT,I AM GOING WITH FAKE EXPERIENCE,SO WHAT I HAVE TO DO.