Please find below mock question from ejbcertificate.com:
Which of the following statements regarding session beans are true? [Check all correct answers]
1. Invoking javax.ejb.EJBObject.getPrimaryKey() on a session bean results in javax.ejb.EJBException been thrown.
2. Invoking javax.ejb.EJBLocalObject.getPrimaryKey() on a session bean results in javax.ejb.EJBException been thrown.
3. Invoking javax.ejb.EJBHome.remove(java.lang.Object primaryKey) on a session bean results in javax.ejb.RemoveException been thrown.
4. Invoking javax.ejb.EJBLocalHome.remove(java.lang.Object primaryKey) on a session bean results in javax.ejb.RemoveException been thrown.
5. Invoking javax.ejb.EJBHome.remove(java.lang.Object primaryKey) on a session bean results in java.rmi.RemoteException been thrown.
You have answered: 2 3 4
Explanation:
Answer 2 and 5 are correct. Answer 2 is correct because the method javax.ejb.EJBLocalObject.getPrimaryKey() can only be invoked on an entity bean. An attempt to invoke the method on a session bean results in javax.ejb.EJBException been thrown. Answer 5 is correct because javax.ejb.EJBHome.remove(java.lang.Object primaryKey) can only be invoked on an entity bean. An attempt to invoke the method on a session bean results in java.rmi.RemoteException been thrown.
Answers 1, 3 and 4 are incorrect. Any methods associated with a primary key defined by a local home or component interface raises a javax.ejb.EJBException if the method is invoked on a session bean. Likewise, any methods associated with a primary key defined by a remote home or component interface raises a java.rmi.RemoteException if the method is invoked on a session bean.
My Explanation: Answer 5 is wrong.
Please refer section
"6.6 Session object identity" of EJB Specification which clrealy states as mentioned below:
EJBHome.remove(Object primaryKey) and the EJBLocalHome.remove(Object primaryKey)methods result in a javax.ejb.RemoveException if called on a session bean. So correct answers are 2, 3 and 4.
Any comments on above?
[ November 04, 2004: Message edited by: Sandesh Tathare ]
Regards,<br />Sandesh<br />(SCJCP, SCWCD, SCBCD - 99%, OCP-1)<br /> <br />Either find a way or create one.