Forums Register Login

Question on Exceptions

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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 ]
money grubbing section goes here:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 590 times.
Similar Threads
Exception questions
Exception Inheritance Hierarchy
Weblogic 7.0 certification mock test question
Doubt on send Error
Doubt on Whizlabs Mock Test Question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:06:33.