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 the difference between throw and throws?

5 Answers   Cap Gemini,


What are predicates in java 8?

0 Answers  


In Java, what types of classes perform inheritance?

2 Answers  


What is default size of arraylist in java?

0 Answers  


What is difference between local variable and global variable?

0 Answers  


How do you clear a list in java?

0 Answers  


Can substring create new object?

0 Answers  


How does hashmap work in java ?

0 Answers  


Can we declare a class as static?

0 Answers  


what is the use of custom tags? with example?

1 Answers   Photon,


Can a class extend more than one class?

0 Answers  


What are the different types of collections in java?

0 Answers  


Categories