Originally posted by Valentin Crettaz:
Please tell us which exam provides this mock question.
There's a red flag if I've ever seen one.
Originally posted by Senthil Gangatharan:
The Correct answer is E.
Almost there but not quite, check the API docs:
EJBObject EJBLocalObject EJBObject.remove() throws RemoveException (Checked, Application Exception) and RemoteException (Checked, System Exception)
EJBLocalObject.remove() throws RemoveException (Checked, Application Exception) and EJBException (Unchecked, System Exception)
Now if the question would have asked "without application exception" and on an "Entity Bean" it would be C.
EJBObject.getPrimaryKey() throws RemoteException (Checked, System Exception)
EJBLocalObject.getPrimaryKey() throws EJBException (Unchecked, System Exception)
But of course on a session bean getPrimaryKey() will throw a system exception.
On a "stateless session bean" the answer would be E for the first time that "remove()" is called because the method doesn't do anything. However the second time "remove()" is called a NoSuchObjectException/NoSuchObjectException will be thrown - the question could have sidestepped that one by asking "without application exception".
EJB 2.0 spec page 79.
When the client calls remove on the home or component interface to remove the session object, the container issues ejbRemove() on the bean instance. This ends the life of the session bean instance and the associated session object. Any subsequent attempt by its client to invoke the session object causes the java.rmi.NoSuchObjectException to be thrown if the client is a remote client, or the javax.ejb.NoSuchObjectLocalException if the client is a local client. (The java.rmi.NoSuchObjectException is a subclass of the java.rmi.RemoteException; the javax.ejb.NoSuchObjectLocalException is a subclass of the javax.ejb.EJBException). The ejbRemove() method cannot be called when the instance is participating in a transaction. An attempt to remove a session object while the object is in a transaction will cause the container to throw the javax.ejb.RemoveException to the client. Note that a container can also invoke the ejbRemove() method on the instance without a client call to remove the session object after the lifetime of the EJB object has expired.
On a "stateful session bean" calling "remove()" has the risk of a RemoveException.
Lesson 1.: Mock questions are (mostly) a waste of time - i.e. don't spend too much time on them.
Lesson 2.: If you need mock questions for a warm up
at the end of your studies only use them if they come from a reputable source that does the technical research to come up with high quality questions, answers
and justifications for the answers.
For example, I know I'm probably going to break down and get Whizlab's SCDJWS simulator because there is no study guide (which would normally provide mock questions) simply because I don't care for taking (and paying for) any exam twice. At the end of my studies I want to know if I've covered all the bases - even though I will loath each 2 hour session that I feel would be better spent doing some more reading, research, coding or
testing.
[ October 14, 2005: Message edited by: Peer Reynders ]