if try is followed by finally block what happen to exception
occured in try block

Answers were Sorted based on User's Feedback



if try is followed by finally block what happen to exception occured in try block..

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

if try is followed by finally block what happen to exception occured in try block..

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

if try is followed by finally block what happen to exception occured in try block..

Answer / raju

error occurs

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More Programming Languages AllOther Interview Questions

Ordered List tag is

1 Answers  


can u help me? how do solve the transpose problem in ireport? if any one know send to eswaran_2006@yahoo.co.in

0 Answers  


write algo for cobol program whichuse three flat file to extract some specific information 8 marks mainframe

0 Answers  


How can recruiter justified that the candidate is expert in Algorithm and datastructure for Software product development ?

0 Answers  


5.Call by value and Call by reference with program?

0 Answers  






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.

1 Answers  


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?

0 Answers  


Delta 5 weight scale not connect with oracle application what i can do?

0 Answers  


What do you mean by an array ? explain with an example

7 Answers  


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?

0 Answers   Symphony,


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.

3 Answers  


Categories