It's not a secret anymore!
The moose likes Mock Exam Errata and the fly likes Possible Java Rule Round-up Ambiguity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Bookmark "Possible Java Rule Round-up Ambiguity " Watch "Possible Java Rule Round-up Ambiguity " New topic

Possible Java Rule Round-up Ambiguity

Joseph Maddison
Ranch Hand

Joined: Nov 04, 2004
Posts: 53
In regard to the question,

#98, All Exceptions inherit from:


I chose java.lang.Exception-- all Exceptions are subclasses of this one. The offical answer, java.lang.Throwable comes with a comment (which is true!) "The Exception hierarchy begins at java.lang.Throwable."

That's true, but I didn't interpret the original question as "Where does the Exception hierarchy begin?" or I would have chosen java.lang.Throwable. Am I way off here?

For a significant number of questions (on every exam prep, not just in the Round-up), it seems there is an easy answer and a tricky answer (especially for true/false), but it's not consistent which one is the one to choose. I'll post better examples of this when I run into other instances.

Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
I suppose the question is, does Exception itself inherit from Exception? That depends on your definition of "inherit". Some might argue that a class inherits from itself. OK. But a careful reading of the Java Language Specification indicates that, as used in the Java programming language, a class does not inherit from itself. So according to the JLS, your interpretation is incorrect.

More pragmatically, according to your interpretation there should be two correct answers, yes? Both Exception and Throwable would work. So - how many answers does the question allow you to provide? If the question allows multiple responses, then maybe you should answer both Exception and Throwable. (I wouldn't, for the a reasons given in my first paragraph, but maybe you diesagree...) But if the question allows only one answer (as is the case in the rules roundup, I think) then you need to decide - what is the best answer? Exception, which is true only if you interpret "inherit" a certain way? Or Throwable, which is always, inarguably, true? Dunno about you, but I know which one I'd choose...

The actual SCJP exam exam will almost certainly tell you how many answers to pick, if more than one answer is expected. Which makes things easier - you just need to focus on what is the best answer (or best N answers). Many mock exams are not written this way, so you may be getting the wrong idea about what actual exam questions are like. (In the past, exam questions were written differently than they are nowadays.) So don't worry too much about this issue - just concentrate on learning how Java works.

"I'm not back." - Bill Harding, Twister
Rajith Vidanaarachchi

Joined: Nov 06, 2004
Posts: 11
I'll post a simple and easy example for your question.
Do you know that the class Exception it self os an exception. That we can throw just Exception. So now you are saying that all the exceptions inherit from(are subclasses of)the class Exception. Due to my knowledge a class can't extend itself. I think you understand now.
I agree. Here's the link:
subject: Possible Java Rule Round-up Ambiguity
It's not a secret anymore!