Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.08 KB

153d.md

File metadata and controls

33 lines (20 loc) · 1.08 KB

Back to questions

153d: Exceptions and inheritance (iii)

Consider the following hierarchy of exceptions:

A.java

B.java

C.java

Carefully examine the following program, which throws instances of A, B and C:

Demo.java

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.