What will happen if we write code like:
try{}catch(exception e)catch(IOException i)

Answers were Sorted based on User's Feedback



What will happen if we write code like: try{}catch(exception e)catch(IOException i)..

Answer / guest

It will not compile.

Is This Answer Correct ?    26 Yes 8 No

What will happen if we write code like: try{}catch(exception e)catch(IOException i)..

Answer / sitaram

it is not complied. because first catch having child
exception and last exception having parent exception is must.
correct answer is :
try{
}
catch(IOException i){
}
catch(Exception e){
}

Is This Answer Correct ?    19 Yes 2 No

What will happen if we write code like: try{}catch(exception e)catch(IOException i)..

Answer / maurice johnson

Ignoring the incorrect syntax of the Try\Catch Block, it
will never reach the IOException portion of the
Catch......the first catch will always be triggered due to
it only Catching type Exception.

Is This Answer Correct ?    12 Yes 3 No

What will happen if we write code like: try{}catch(exception e)catch(IOException i)..

Answer / jahri

yes it should be child exception to base exception

Is This Answer Correct ?    4 Yes 1 No

What will happen if we write code like: try{}catch(exception e)catch(IOException i)..

Answer / mathi

Ignoring the incorrect syntax of the Try\Catch Block, it
will never reach the IOException portion of the
Catch......the first catch will always be triggered due to
it only Catching type Exception.

Is This Answer Correct ?    1 Yes 1 No

What will happen if we write code like: try{}catch(exception e)catch(IOException i)..

Answer / sonal

I knew the answer but tried it to get the exact compile
time error. It reads "exception java.io.IOException is
already been caught".

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More Core Java Interview Questions

what is difference between method overloading & method overridding with example?

4 Answers   IBM,


Can an interface extands a class?

5 Answers  


What is the loop in java?

0 Answers  


What is wrapper class html?

0 Answers  


What is Classloader in Java?

0 Answers  






What is the difference between assignment and initialization?

0 Answers  


Which is bigger double or float?

0 Answers  


What is byte [] in java?

0 Answers  


What is definition and declaration?

0 Answers  


How do I start learning java?

0 Answers  


What do you mean by a JVM?

0 Answers   GE,


If an object is garbage collected, can it become reachable again?

0 Answers  


Categories