aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Throwable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Throwable" Watch "Throwable" New topic
Author

Throwable

krussi rong
Ranch Hand

Joined: Jan 30, 2002
Posts: 62
Hi,
here is the question:

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
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


SCJP Tipline, etc.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
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.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
krussi rong
Ranch Hand

Joined: Jan 30, 2002
Posts: 62
thanks guys!
Krussi
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Throwable
 
Similar Threads
To throw or not to throw?!
swith and case statements
choosing the Classes
Exception
doubt on mock exam question?