Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Exceptions

 
Sunil Dumpala
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I encountered a question on Exceptions in a mock test

Which of the following exceptions are considered as application exceptions?
(Select 2 correct options)
A. java.rmi.RemoteException
B. java.lang.ArrayIndexOutOfBoundsException
C. java.io.IOException
D. javax.ejb.EJBException
E. Any exception that extends from java.lang.Exception but not from java.lang.RuntimeException
F. java.lang.Exception

The answers suggested by the mock test tool are C,F.

I don't understand how F could be an answer. Application exceptions are the exceptions which are subclass of Exception, not a sub-class of RuntimeException and not RemoteException. If I have to pick an answer I would rather pick E for an answer. Anybody any comments on this?

Thanks,
Sunil
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a spec knowledge question. The problem in the E answer is that one exception is forgotten (java.rmi.RemoteException), so it's incomplete, hence wrong.

Spec states (P. 372) :
An application exception class must be a subclass (direct or indirect) of java.lang.Exception.
An application exception class must not be defined as a subclass of the java.lang.RuntimeException
or of the java.rmi.RemoteException.


SO :
A. java.rmi.RemoteException
No, see spec.
B. java.lang.ArrayIndexOutOfBoundsException
No, extends RuntimeException
C. java.io.IOException
Yes
D. javax.ejb.EJBException
No, extends RuntimeException
E. Any exception that extends from java.lang.Exception but not from java.lang.RuntimeException
No, incomplete, misses RemoteException
F. java.lang.Exception
Yes, see first sentence of quoted spec.

Hope this is clear.
[ March 29, 2006: Message edited by: Frederic Esnault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic