1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types and Exceptions in Java

Connected

Exercise

(Re)Throwing

When a method throws an exception, the calling method must handle that exception. To handle it, it can try/catch the exception or rethrow it. In this exercise, you will see how a calling method rethrows an exception.

Instructions

100 XP
  • Call the dineOut() method with 9 people triggering the Exception.
  • Since the dineOut() method is not handling the exception, rethrow the Exception.
  • Since the splitBill() method is not handling the exception, throw the Exception.