JavaBeat Feeds
|
|
|
|
|
|
|
|
|
|
SCBCD Mock Questions - 14
1)Which of the following SessionContext methods is a disallowed operation for a session bean with container-managed transaction demaraction?
1)getEJBHome()
2)getCallerPrinciple()
3)getEJBObject()
4)getUserTransaction()
5)isCallerInRole()
2)Which of the following statements regarding the lifecycle of a session bean are correct?
1)java.lang.IllegalStateException is thrown if SessionContext.getEJBObject() is invoked when a stateful session bean instance is passivated.
2)SessionContext.getRollbackOnly() does not throw an exception when a session bean with bean-managed transaction demarcation is activated.
3)An exception is not thrown when SessionContext.getUserTransaction() is called in the afterBegin method of a bean with container-managed transactions.
4)JNDI access to java:comp/env is permitted in all the SessionSynchronization methods of a stateful session bean with container-managed transaction demarcation.
5)Accessing resource managers in the SessionSynchronization.afterBegin method of a stateful session bean with bean-managed transaction does not throw an exception.
3)Which of the following statements regarding the lifecycle of a session bean are correct? [Select all correct answers]
1)java.lang.IllegalStateException is thrown if setRollbackOnly() is called in a container-managed session bean's business method that has been declared with the Required transaction attribute.
2)Calling getCallerPrincipal() is disallowed in the session bean methods for which the container does not have a meaningful transaction context.
3)The UserTransaction interface is available to enterprise beans with bean-managed transaction demarcation.
4)Calling getEJBObject() in a session bean instance method is disallowed if the session bean does not define a remote client view.
5)All container providers must support the SessionSynchronization interface.
4)Given the following fragment of code of a stateful session bean, which of the following scenarios result in the session bean being removed by the container without closing the database connection?
Assume that all reference variables have been declared
properly and the code has been compiled successfully.
InvalidExamException is a subclass of java.lang.Exception.
public void ejbCreate() throws CreateException {
// obtain database connection
}
public void completeExam() throws InvalidExamException {
...
try {
PreparedStatement stmt = con.prepareStatement(
"update exam set status='complete'");
stmt.execute();
} catch (SQLException e) {
throw new EJBException(e);
}
...
}
public void ejbRemove() {
try {
con.close();
} catch (SQLException se) {
throw new EJBException(e);
}
}
1)completeExam() throws InvalidExamException.
2)The SQL statement fails to update the exam table in the completeExam() method.
3)The bean instance have been activated at least one.
4)The bean instance is passivated.
5)The client calls remove() on the corresponding session object.
5)What is the correct sequence order of method calls made by the container in order to place a stateful session bean in the method ready state?
1)create, constructor, setSessionContext, ejbCreate
2)constructor, ejbCreate, setSessionContext, ejbActive
3)constructor, setSessionContext, ejbCreate
4)setSessionContext, ejbActivate, ejbCreate
5)ejbCreate, ejbActivate, setSessionContext
6)Which of the following statements regarding the lifecycle of a stateless session bean are correct? [Select all correct answers]
1)Stateless session beans are never passivated; the ejbActivate and ejbPassivate methods are never called.
2)afterBegin, beforeCompletion and aftercompletion are callbacks methods made by the container if a container-managed stateless session bean implements the SessionSychronization interface.
3)Stateless session beans are not associated with a particular client. The container simply delegates to any free bean instance in the pool.
4)When a client invokes the create method on a stateless session bean's home interface, the container always invokes newInstance on the session bean class to create a stateless instance
5)When a client invokes the remove method on a stateless session bean's home interface, the container always removes the corresponding stateless instance from the method-ready pool
7)Given that a stateful session bean implements the SessionSychronisation interface, select the correct order in which a container calls a transactional business method that throws a system exception.
1)beforeBegin(), business method, afterCompletion().
2)beforeBegin(), business method, beforeCompletion(), afterCompletion()
3)beforeBegin(), afterBegin(), business method, afterCompletion().
4)afterBegin(), business method, beforeCompletion(), afterCompletion().
5)afterBegin(), business method, afterCompletion().
8)Which method can access an enterprise bean in a consistent manner for a container managed stateful session bean that implements the SessionSynchronization interface?
1)constructor()
2)setSessionContext()
3)ejbCreate()
4)beforeCompletion()
5)afterCompletion()
9)Which of the following SessionContext methods are accessible in the setSessionContext method of a session bean class? [Select all correct answers]
1)getEJBHome()
2)getEJBLocalHome()
3)getEJBObject()
4)getEJBLocalObject()
5)getCallerPrinciple()
10)Which of the given scenarios result in a session bean instance being removed by the container without calling ejbRemove() on the bean instance?
1)When a transaction is rolled back in a bean instance's method.
2)The bean instance is passivated.
3)The bean instance has timed out whilst in the passivated state.
4)The bean instance is removed from the method-ready pool.
5)A bean instance throws an application exception to the container
|