• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client View of a Session Bean - Mock Question

 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Peter Rooke
Ranch Hand
Posts: 851
1
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only yesterday, creating session beans [and the specification] were answered (but, I got it a bit wrong at first)

CMP and specification.
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

The answers provided by ejbcertificate.com was wrong. Today I received confirmation from their end. They have updated their database accordingly.

Thanks ejbcertificate.com team for providing lovely site for testing our knowledge.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic