Which statements about session beans are true? (Choose all that apply.)
Which list(s) correctly sequence some of the steps in a session bean’s lifecycle? (Choose all that apply.)
Which types of session bean instance fields can be successfully passivated and reactivated? (Choose all that apply.)
Which are valid remote component interfaces for a session bean? (Choose all that apply.)
A.
public interface MyBean extends javax.ejb.EJBObject { void myMethod(); }
B.
public interface MyBean extends javax.ejb.EJBObject throws RemoteException { void myMethod(); }
C.
public interface MyBean extends javax.ejb.EJBHomeObject { void myMethod() throws RemoteException; }
D.
public interface MyBean extends javax.ejb.EJBObject { void myMethod() throws RemoteException; }
If a client makes a call to a session object that has been removed by the container, which exceptions can be thrown? (Choose all that apply.)
Given:
15.
MyBean create(String name) throws CreateException, RemoteException;
Which session bean interface can contain this method?
What is true about a session bean’s lifecycle? (Choose all that apply.)
A.
If a business method throws a system exception the bean will be passivated.
B.
A passivated bean must be activated before it can be removed.
C.
A stateless session bean’s removal must be initiated by the client not the container.
D.
Stateless session beans cannot implement the SessionSynchronization interface.
Which are required of the bean provider to ensure that a session bean is successfully passivated? (Choose all that apply.)
A.
The provider must call
ejbPassivate().
B.
The provider must always add business logic to the
ejbPassivate()
method, if the bean is stateful.C.
The provider must close any database connections before
ejbPassivate()
completes.D.
The provider must assume that any state stored in instance fields marked transient will be lost.
E.
The provider must assume that any reference to the SessionContext object will be not survive passivation if the SessionContext object is not serializable.
Given a stateless session bean with container-managed transaction demarcation, from which method(s) can you access another bean? (Choose all that apply.)
(Note: The real exam has several types of ‘drag and drop’ questions, that we’re going to do a lame job of simulating with this question...)
Match the methods on the left with the interfaces in which those methods can be found, on the right. A match is correct if the method is either declared in, or inherited by, the interface. Note: There may be some many-to-one and one-to-many relationships in your answer.
afterCompletion
getUserTransaction
afterBegin
isCallerInRole
getRollBackOnly
setSessionContext
setRollbackOnly
SessionSynchronization
SessionContext
SessionBean
UserTransaction
What is true about a session bean’s lifecycle? (Choose all that apply.)
A.
The container will always create a new session bean instance when the client invokes the
create()
method on the home interface of a stateless bean.B.
The container will always call
ejbRemove()
when the client invokes theremove()
method on a stateless bean’s home interface.C.
A session bean cannot be passivated while it is in a transaction.
D.
The
setSessionContext()
method is not invoked during a stateless bean’s lifecycleWhich of the following methods are container callback methods? (Choose all that apply.)
In what case(s) will the container fail to call ejbRemove() on a session bean? (Choose all that apply.)
Which method(s) allow both stateful and stateless session beans with bean-managed transaction demarcation to access UserTransaction methods? (Choose all that apply.)
For which type of bean can the container passivate an instance that is in a transaction?
For session beans, which are the responsibility of the Container? (Choose all that apply.)
For this drag and drop type question, you can use each element only once. Which interface should be matched with which fact, so that all four matches are correct?
remote component
remote home
local component
local home
Has a
getHomeHandle()
methodextends
'javax.ejb.EJBObject'
methods must NOT throw
'java.rmi.RemoteException'
can be used to retrieve an EJBLocalObject
Which can be called by the container during the lifecycle of a session bean? (Choose all that apply.)
Which statements about a session bean class are true? (Choose all that apply.)
For which type of bean can the SessionSynchronization interface be implemented?
Which statements are true for stateless session bean instances? (Choose all that apply.)
Get Head First EJB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.