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

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

0 Answers  


Explain polymorphism. Provide an example.

0 Answers   Amazon,


hai i am prasanna.I am MCA 2009 fresher.tell me about certifications.which certification helps me to improve my carrier and to get a technically oriented job ,which certification helps to get job faster.

0 Answers  


How to call static method in Java?

2 Answers   Epoch,


what is the difference between java , sap ,.net , orecle apps ?

1 Answers  


i want to insert textbox value to sql db. i have only one text box but store four values. ple give any one give sample code in asp.net c#..

1 Answers   Concentrix,


Given three sides of a triangle. Write the Program to determine whether the triangle is : 1) Invalid 2) Right Angled 3) Isoscales 4) Equilateral 5) Not Special An Isoscales right angled triangle should be taken as a Right Angled Triangle

3 Answers   FFC, Goldman Sachs, Student,


what type of exceptions & problems are faced in production time at java technology?

0 Answers   CTS,


In staad pro, how can we design ROOF SLAB?

0 Answers   L&T,


A good website has the following conditions It should be interactive. It should contain at least 20 images. Title cannot be null and should contain at least 10 letters other than spaces and hyphen (-). The keywords should contain atleast three among the following list : "design", "Graphics", "lovely", "beautiful", "amazing" and "mesmerising" Write a method: boolean isGoodWebsite(boolean isInteractive, int numOfImages, String title,String keywords[]) isInteractive whether the site is interactive or not numOfImages Number of images on the website title Title of the website keywords Array of keywords in the website.

0 Answers  


Even if all fields are initialized also in a program, I am getting COBOL/400 decimal data error .why is it coming?

1 Answers   Freelance,


what is delegate and how works delegate and event.

0 Answers   NIIT,


Categories