Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question #226 -- wrong answer  RSS feed

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question reads:
"(#226)All exceptions inherit from:"
The choices were exception error and throwable. Technically all exceptions extend java.lang.exception, as well as java.lang.throwable, so both of those choices should be correct. The question only excepts an answer of java.lang.throwable
ray
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(#226)All exceptions inherit from:
java.lang.Throwable
java.lang.Error
java.lang.Exception
.........
You're right.
What might be a better way to ask this question?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider:
<code><pre> throw new Exception("A plain old Exception");</pre></code>
Does this object inherit from Exception? I'd say no, it is an exception. It's an exception which does not inherit from Exception. Maybe others interpret "inherit" a bit differently though.
If you want to be safe, just drop the Exception option. (I was going to suggest "extend" instead of "inherit", but there are ambiguities there too with direct extension vs. indirect extension.) You can put in java.lang.RuntimeException and java.lang.BaseExpression instead. Or Java.lang.Tossable.
 
Paul Caudle
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could just invert the question, placing what was the answer in the top, and the question as the answer. Like this:
Which class inherits from java.lang.Throwable?
java.lang.Exception
java.lang.RuntimeException
java.lang.Error
all of the above
none of the above
Me, I would choose all of the above. Anyway, just a suggestion

[This message has been edited by Paul Caudle (edited June 15, 2000).]
 
Deepoo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Wheaton:
(#226)All exceptions inherit from:
java.lang.Throwable
java.lang.Error
java.lang.Exception
.........
You're right.
What might be a better way to ask this question?

Paul,
A better way to frame this question would be to ask the person to pick the class that is NOT part of the inheritance hierarchy of an exception class.
-----------------------------------------------------------------
(#226) All exceptions inherit/extend from the classes below, except
1. java.lang.Throwable
2. java.lang.Error
3. java.lang.Exception
-----------------------------------------------------------------
Deepak

[This message has been edited by Deepoo (edited June 15, 2000).]
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In reading all this I had an idea. How about
What is the root class for the type of object that can be used in a catch statement?
Exception
RuntimeException
Error
Throwable
Catchable
Whaddya think?
 
Paul Caudle
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds good to me. I like it. I say go for it
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that "Object" is the root class of everything, and is not on the list!
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about making the question a little broader.
"What class to all Errors and Exceptions inherit from?"
and have the same three options.
Errors do not inherit from java.lang.Exception, but do inherit from Throwable.
What do you think?
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela, I think that makes the question easier! I want these questions to be tough! I also want them to be accurate and unambiguous.
Frank, I think you are right, I should add Object to the list too. The key being that you cannot catch any Object.
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made the change, but I'm worried that it all might be too big for the applet now.
Can somebody go through the applet and try to find this question again and see if it is okay?
 
Angela Poynton
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if you intended thiis but all I see is:
What is the root class for the object used in the catch statement
java.lang.Throwable;
java.lang Error;
Did you intend to give more options?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!