What is unreachable code and how might using multiple catch blocks cause this? Provide an example.
What will be an ideal response?
When you list multiple catch blocks following a try block, you must be careful that some catch blocks don't become unreachable. Unreachable statements are program statements that can never execute under any circumstances. For example, if two successive catch blocks catch an ArithmeticException and an ordinary Exception, respectively, the ArithmeticException errors cause the first catch to execute and other types that derive from Exception"fall through" to the more general Exceptioncatch block. However, if you reverse the sequence of the catch blocks so the one that catches general Exception objects is first, even ArithmeticExceptions would be caught by the Exception catch. The ArithmeticExceptioncatch block therefore is unreachable because the Exceptioncatch block is in its way and the class does not compile.
You might also like to view...
The IEEE defines three general categories of Ethernet MAC addresses. What are these three types?
A) Anycast B) Unicast C) Loopback D) Broadcast E) Singlecast F) Multicast
MC Sequences are unpacked with the______operator.
a) :. b) ( ). c) =. d) [ ].