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

what is difference between restoring and non restoring division?

2 Answers   Texas,


what you mean by mantis in IT interview? why we use mantis? advantage of mantis?

1 Answers  


What do you understand by modular programming?

0 Answers   Tech Mahindra,


3.Give the formula for determine the range of the data type?

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  


ok how would i do the following extract from a file i have ssns = 267907230 which are in column 7 into a separate data set then create a 2nd job step to extract from the data set created the following "fund code" which is in column 31 and is 113 into yet another data set

0 Answers  


you have an unlimited supply of $3 and $7 poker chips. What is the largest integer value that you cannot make by combining different numbers of chips?

2 Answers  


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

0 Answers   TCS,


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  


Can we write a method in JSP.If so how?

0 Answers   HCL,


Hai, My name is nisha.I have NIC exam.If anybody Knows NIC previous paper pattern pls send me to nishanairp@gmail.com

0 Answers  


What is the use of sas software? Is sas and sap are different?

0 Answers  


Categories