Hey all,
I have some doubt over the answer to one of the drag and drop questions:
Create a valid EJB3.0 exception that is a runtime exception
<blank1>
public class <blank2> extends <blank3>
Options: @ApplicationException MyException RuntimeException RemoteException EJBException @EJBException
I put my answer as:
blank1 = @ApplicationException
blank2 = MyException
blank3 = EJBException
so the answer would look like:
@ApplicationException
public class MyException extends EJBException.
This is was not marked as being correct. Instead 'EJBException' should be swapped with 'RuntimeException'. Although this seems like the most obvious answer and is correct, EJBException extends RuntimeException, so doesn't that mean that MyException "is a" EJBException which "is a" RuntimeException?
The answer explanation gives:
An application exception that is an unchecked (i.e. Runtime) exception is defined as an application exception by annotating it with the ApplicationException metadata annotation, or denoting it in the deployment descriptor with the application-exception element.
Remember that EJBException extends RuntimeException but it is not an application exception because it is not annotated with @ApplicationException.
The second paragraph doesn't justify my answer from being incorrect does it, since I annotated MyException as an ApplicationException which through inheritance is a RuntimeException?