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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the Difference between in memory database and physical database

2310


WHAT IS MAIN IMPORTANT THING IN SOFTWARE?

1941


design a counter with the following repeated binary sequence: 0, 1, 2, 3, 4, 5, 6, 7, 8 using JK Flip Flop.

16922


Hi I am Rathnam, How To Remove the duplicates with out using remove duplicate stage in the datastage

1713


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

2035


I want to pass .pdf files as OlE Object to crystal report through VB6. Please any one guid me...

2802


Explain polymorphism. Provide an example.

783


Write a shell program. Enter number of days from keyboard. Find out the number of years, month and days it contains

1771


a characteristic of a multiprogramming is? a.simultaneous exe of pgm instr 4m 2 appli b.concurrent processing of 2 r more prgms c.multiple cpu s d.all the abov

1902


Compare any 4 software development life cycle paradigms with each other. Indicate at least one application for each of the paradigms that are suitable to developed using that paradigm.

2574


Tips for blog integration by www.esteemwebsolutions.com. Can Any body suggest me to how to make wonderful questions on web integration..

1882


4. What is the need of START 0? Instead if can we use any other numeric? If we use what will happen?

2115


how do u handle table control inbdc explain the process in steps iwant the answer in urgent please forward this even i know how to explain there

1962


Write a program to show polymorphism.

848


How do i find out the number of parameters passed into function?

2407