11.15 Exercises, Problems, and Projects

11.15.1 Multiple Choice Exercises

  1.   1. Why are try/catch blocks useful?

    • ❑ They can replace selection statements, thus saving CPU time.

    • try/catch blocks enable programmers to attempt to recover from illegal situations and continue running the program.

  2.   2. Some methods that throw an exception require try and catch blocks, while some do not.

    • ❑ true

    • ❑ false

  3.   3. What keyword is found in the header of a method that could detect an error and generate an appropriate exception?

    • throw

    • throws

    • exception

    • exceptions

  4.   4. When coding a try and catch block, it is mandatory to code a finally block.

    • ❑ true

    • ❑ false

  5.   5. Most input- and output-related classes can be found in the package ...

Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.