• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on Exceptions

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic