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 about instanceof operator in java?

0 Answers  


What is a function in java?

0 Answers  


What does java stand for?

0 Answers  


What do you mean by compiler?

0 Answers  


Give the difference between the println method and sqrt method?

0 Answers  






What is the use of java?

0 Answers  


What is mean by collections in java?

0 Answers  


What is a constructor overloading in java?

0 Answers  


Is a char always 1 byte?

0 Answers  


Why all programming languages have main as a execution starting point?

4 Answers  


How many bits is a string?

0 Answers  


Explain about fail fast iterators in java?

0 Answers  


Categories