which of the following must be true of the object thrown by a throw statement? 1.It must be assignable to the Throwable type. 2.It must be assignable to the Error type. 3.It must be assignable to the Exception type. 4.It must be assignable to the String type. so why the answer is 1 ? but I think is 1.2.3 thanks Jenny
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
posted
0
Exceptions and Errors are descendents of the class Throwable. You are only allowed to throw any object that descends from Throwable. As Error and Exception are siblings, if #2 was true, you couldn't throw Exceptions and if #3 was true, you couldn't throw Errors. The only correct answer is #1. I hope that helps, Corey
It's the "must be" that makes it only #1. It can be assignable to Exception (since Exception is a child of Throwable) but it must be assignable to Throwable.