Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Java Sample Questions ›› EJB Java Sample Questions

Java Technical Sample Questions : EJB Sample Questions

  1. How is persistence implemented in enterprise beans?

    Answer: Persistence in EJB is taken care of in two ways, depending on how you implement your beans: container managed persistence (CMP) or bean managed persistence (BMP) For CMP, the EJB container which your beans run under takes care of the persistence of the fields you have declared to be persisted with the database - this declaration is in the deployment descriptor.So, anytime you modify a field in a CMP bean, as soon as the method you have executed is finished, the new data is persisted to the database by the container.For BMP, the EJB bean developer is responsible for defining the persistence routines in the proper places in the bean, for instance, the ejbCreate(), ejbStore(), ejbRemove() methods would be developed by the bean developer to make calls to the database.The container is responsible, in BMP, to call the appropriate method on the bean.So, if the bean is being looked up, when the create() method is called on the Home interface, then the container is responsible for calling the ejbCreate() method in the bean, which should have functionality inside for going to the database and looking up the data.

  2. What is an EJB Context?

    Answer: EJBContext is an interface that is implemented by the container, and it is also a part of the bean-container contract.Entity beans use a subclass of EJBContext called EntityContext.Session beans use a subclass called SessionContext.These EJBContext objects provide the bean class with information about its container, the client using the bean and the bean itself.They also provide other functions.See the API docs and the spec for more details.

  3. Is method overloading allowed in EJB?

    Answer: Yes you can overload methods

  4. Should synchronization primitives be used on bean methods?

    Answer: No.The EJB specification specifically states that the enterprise bean is not allowed to use thread primitives.The container is responsible for managing concurrent access to beans at runtime.

  5. Are we allowed to change the transaction isolation property in middle of a transaction?

    Answer: No.You cannot change the transaction isolation level in the middle of transaction.

  6. For Entity Beans, What happens to an instance field not mapped to any persistent storage, when the bean is passivated?

    Answer: The specification infers that the container never serializes an instance of an Entity bean (unlike stateful session beans).Thus passivation simply involves moving the bean from the "ready" to the "pooled" bin.So what happens to the contents of an instance variable is controlled by the programmer.Remember that when an entity bean is passivated the instance gets logically disassociated from it's remote object.Be careful here, as the functionality of passivation/activation for Stateless Session, Stateful Session and Entity beans is completely different.For entity beans the ejbPassivate method notifies the entity bean that it is being disassociated with a particular entity prior to reuse or for dereference.

  7. What is a Message Driven Bean, what functions does a message driven bean have and how do they work in collaboration with JMS?

    Answer: Message driven beans are the latest addition to the family of component bean types defined by the EJB specification.The original bean types include session beans, which contain business logic and maintain a state associated with client sessions, and entity beans, which map objects to persistent data.Message driven beans will provide asynchrony to EJB based applications by acting as JMS message consumers.A message bean is associated with a JMS topic or queue and receives JMS messages sent by EJB clients or other beans.Unlike entity beans and session beans, message beans do not have home or remote interfaces.Instead, message driven beans are instantiated by the container as required.Like stateless session beans, message beans maintain no client-specific state, allowing the container to optimally manage a pool of message-bean instances.Clients send JMS messages to message beans in exactly the same manner as they would send messages to any other JMS destination.This similarity is a fundamental design goal of the JMS capabilities of the new specification.To receive JMS messages, message driven beans implement the javax.jms.MessageListener interface, which defines a single "onMessage()" method.When a message arrives, the container ensures that a message bean corresponding to the message topic/queue exists (instantiating it if necessary), and calls its onMessage method passing the client's message as the single argument.The message bean's implementation of this method contains the business logic required to process the message.Note that session beans and entity beans are not allowed to function as message beans.

  8. Does RMI-IIOP support code downloading for Java objects sent by value across an IIOP connection in the same way as RMI does across a JRMP connection?

    Answer: Yes.The JDK 1.2 support the dynamic class loading.

  9. The EJB container implements the EJBHome and EJBObject classes.For every request from a unique client, does the container create a separate instance of the generated EJBHome and EJBObject classes?

    Answer: The EJB container maintains an instance pool.The container uses these instances for the EJB Home reference irrespective of the client request.while refering the EJB Object classes the container creates a separate instance for each client request.The instance pool maintainence is up to the implementation of the container.If the container provides one, it is available otherwise it is not mandatory for the provider to implement it.Having said that, yes most of the container providers implement the pooling functionality to increase the performance of the application server.The way it is implemented is again up to the implementer.

  10. What is the advantage of putting an Entity Bean instance from the "Ready State" to "Pooled state"?

    Answer: The idea of the "Pooled State" is to allow a container to maintain a pool of entity beans that has been created, but has not been yet "synchronized" or assigned to an EJBObject.This mean that the instances do represent entity beans, but they can be used only for serving Home methods (create or findBy), since those methods do not relay on the specific values of the bean.All these instances are, in fact, exactly the same, so, they do not have meaningful state.Jon Thorarinsson has also added: It can be looked at it this way: If no client is using an entity bean of a particular type there is no need for cachig it (the data is persisted in the database).Therefore, in such cases, the container will, after some time, move the entity bean from the "Ready State" to the "Pooled state" to save memory.Then, to save additional memory, the container may begin moving entity beans from the "Pooled State" to the "Does Not Exist State", because even though the bean's cache has been cleared, the bean still takes up some memory just being in the "Pooled State".

« Previous || Next »

EJB Sample Question Number : 1-10| 11-20| 21-30| 31-40| 41-50| 51-60| 61-70| 71-80| 81-89
Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.