• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

J2EE Qtns (Urgent)

Iyn Shri
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can someone give me answers for the following qtns? Will be good if we can discuss..
(1) Which are true about session beans?
A. A client can pass a remote home object reference to another application.
B. The javax.ejb.EJBMetaData interface is intended to allow application assembly
tools to discover information about the session bean, and to allow loose
client/server binding and client-side scripting.
C. The javax.ejb.EJBLocalHome interface defines the method create() which returns
D. The javax.ejb.EJBLocalHome interface defines the method remove(Object primaryKey)
which returns null.
(2) Consider the following session bean class:
import javax.ejb.*;
import javax.naming.*;
import javax.sql.*;
import javax.jms.*;
public class MySessionBean implements SessionBean {
private SessionContext sessionContext;
private Context jndiContext;
private Queue queue;
private UserDefinedClass userDefinedClass;
public void ejbCreate() {
try {
queue = (Queue) jndiContext.lookup("java:comp/env/jms/StockQueue");
} catch (NamingException ne) {
throw new EJBException(ne);
userDefinedClass = new UserDefinedClass();
public void ejbRemove() {...}
public void ejbActivate() {...}
public void ejbPassivate() {...}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
try {
jndiContext = new InitialContext();
} catch (NamingException ne) {
throw new EJBException(ne);
public class UserDefinedClass {
String dummy;
private DataSource dataSource;
public UserDefinedClass() {
try {
dataSource = (DataSource) jndiContext.lookup(
} catch (NamingException ne) {
throw new EJBException(ne);
Which of the following are true about the conversational state?
A. The state of the variable sessionContext is kept after passivation/activation.
B. The state of the variable jndiContext is kept after passivation/activation.
C. The state of the variable queue is kept after passivation/activation.
D. The state of the variable userDefinedClass is kept after passivation/activation.
E. The container must be able to properly save and restore the reference to the
home and component interfaces of the EJBs stored in the instance��s
state even if the classes that implement the object references are not
F. The container may use the object replacement technique
(java.io.ObjectOutputStream/ObjectInputStream) to externalize the home and
component references.
(3) Which are true about session beans? (Choose all that apply)
A. An attempt to remove a session object while the object is in a transaction will
cause the container to throw the IllegalStateException to the client.
B. A session bean class must not implement the session bean's component interface.
C. A session bean class must not implement the ejbCreate() method.
D. The business methods of a session bean must not be declared as final or static.
E. The remote interface methods must not expose the managed collection classes
that are used for CMP entity beans as arguments or results.
(4) Given a CMP entity bean, which of the following statements are correct?
(Choose all that apply)
A. All the exceptions defined in the throws clause of the method of the remote interface
must be defined in the throws clause of the matching method of the enterprise Bean class.
B. The ejbSelect<METHOD>(...) must not be declared as static or abstract.
C. The ejbHome<METHOD>(...) can be declared as final.
D. The return value type of a business method of an entity bean class could be of MyClass defined
as follows:
public class MyClass {
public int result;
public int getResult() { return result; }
public void setResult(int result) { this.result = result; }
E. The throws clause of an ejbPostCreate<METHOD>(...) may define
arbitrary application specific exceptions including javax.ejb.CreateException.
F. The bean provider must always define a query for each finder method in the deployment descriptor.
(5) Which of these is/are correct about exception? (Choose all that apply)
A. When a RemoveException is thrown from the ejbRemove() method of an entity bean
where the corresponding remove() method has CMT attribute Mandatory,
the client will receive this RemoveException.
B. If the Container denies a client access to a business method, the client will
receive RemoteException or EJBException.
C. When a NoSuchObjectException is thrown from an ejbHome<METHOD>(...) method of an entity bean
where the corresponding home method has CMT attribute RequiresNew,
the client's transaction if any must be marked for rollback.
D. When a system exception is thrown from the onMessage() method of a MDB
with BMT, any transaction that has been started, but not yet completed, by the instance
must be marked for rollback.
(6) Which are true about EJB environment? (Choose all that apply)
A. A resource manager connection factory reference is scoped to the EJB whose declaration
contains the resource-ref element.
B. By default, connections to a resource manager are shareable across other EJBs
in the application that use the same resource in the same transaction context.
C. The Deployer must ensure that all the declared resource environment references are bound to
administered objects that exist in the operational environment. The Deployer may use, for
example, the JNDI LinkRef mechanism to create a symbolic link to the actual JNDI name of
the target object.
D. The Deployer should be able to customize an EJB's business logic.
(7) Which is/are true about security responsibilities? (Choose all that apply)
A. The Deployer is responsible for configuring principal mapping for inter-EJB calls.
The management of caller principals passed on inter-EJB invocations is set up
by the Deployer and System Administrator.
B. Security roles are defined by the Bean Provider in the deployment descriptor.
C. The EJB Container can, but is not required to, provide support for multiple
security domains, and/or multiple principal realms.
D. If the client is in a different security domain than the target enterprise
bean, the system administrator is responsible for mapping the principals used by
the client to the principals defined for the enterprise bean.
(8) Which is/are true about ejb security? (Choose all that apply)
A. If the security infrastructure performs principal mapping, the
getCallerPrincipal() method must return the original caller principal.
B. If the run-as security identity is set up for the bean, its method getCallerPrincipal()
returns the principal that corresponds to the run-as security identity.
C. If transactional requests within a single transaction arrive from multiple clients, all requests
within the same transaction must be allowed to be associated with different security context.
D. The Container must allow multiple-deployed enterprise beans to co-exist at runtime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic