Yes. (Because the string "34.56" can't be converted into
an int
).
Here are two of the rules about how try/catch blocks work:
catch{}
block to match the type of exception thrown
gets control.
To make full sense of these rules you need to know more about exception types.
Here is a hierarchy diagram of Exception
:
An ArithmeticException
is thrown for some
types of aritmetic problems,
such as when a division by zero is attempted.
(However, not all aritmetic problems cause an ArithmeticException
.)
In arranging the try{}
blocks, a child class should
appear before any of its ancestors.
If class A is not an ancestor or descendant of class B,
then it doesn't matter which appears first.
Should ArithmeticException
appear before
RunTimeException
in the list of catch
statements?