what is unreachable code problem in multiple catch statements

Answers were Sorted based on User's Feedback



what is unreachable code problem in multiple catch statements..

Answer / deepthi

if v just gve a default exception block,bfre the specific
catch statement it ll create a unreachable code exception
e.g
catch(Exception e)
{System.out.println(unknown exception);}
catch(ArithmeticException e)
{System.out.println("Division by zero");}

Is This Answer Correct ?    6 Yes 0 No

what is unreachable code problem in multiple catch statements..

Answer / sriragv

Subclass exception handler should come first then the
superclass has to come next. Then only code wil compile
otherwise subclass exception will be never reached results
compilation error.

Is This Answer Correct ?    5 Yes 0 No

what is unreachable code problem in multiple catch statements..

Answer / bijoy baby

super class can handle sub class Exception. That's why when
super class handler placed before sub class handler then the
exception object will not thrown to sub class handler.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

Why destructor is not used in java?

0 Answers  


explain local datetime api in java8?

0 Answers  


What is a boolean expression in java?

0 Answers  


How does thread synchronization occurs inside a monitor?

0 Answers  


Can a class be final?

0 Answers  






What is the size of a string in java?

0 Answers  


Is java an ide?

0 Answers  


How to create two different thread class inside a main function?

1 Answers  


Write a program to check for a prime number in java?

0 Answers   Cyient,


What is the purpose of using bufferedinputstream and bufferedoutputstream classes?

0 Answers  


There are 100 keys and values in HashMap.how to get the keys and values?

1 Answers   IBS,


What are the differences between wait() and sleep()?

0 Answers  


Categories