Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Possible Java Rule Round-up Ambiguity

Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!