Consider the following hierarchy of exceptions:
Carefully examine the following program, which throws instances of A
, B
and C
:
What does this program display to the console if you run it with:
- command-line argument "0"
- command-line argument "1"
- command-line argument "2"
- command-line argument "3"
- command-line argument "1.2"
- no command-line arguments
?
In each case, write a brief justification for your answer.
Note: The point of this question is that you should figure out what will be printed offline, without running the program, using your knowledge and understanding of how exceptions work in Java. Once you have worked out what you think gets printed you can double-check this by typing in and running the program.