BRAINBENCH EXAM ON EJB
Exam 1 :
 
1.Which one of the following methods is called once in the lifetime of a container-managed persistence entity bean?
        1.  setEntityContext ( )  
        2.  ejbFind ( )   
        3.  ejbCreate ( )     
A)     4.  ejbRemove()   
        5.  ejbStore()  
2. Which one of the following packages includes the lookup() method?
           1.  javax.ejb   
           2.  javax.jndi   
         *3.  javax.naming         
           4.  java.jndi 
           5.  java.naming
3.    Sample Code  :
        1. InitialContext ic = new InitialContext();
        2. Object o = ic.lookup("testBean/TestBean");
        3. TestHome th= (TestHome)javax.rmi.PortableRemoteObject.narrow(o,TestHome.class);
        4. String result = myTest.userMethod();
        5. myTest.remove();
        6. // Bean state?
       
Question : Assume the application server has just been started. At the commented-marker in the client code above (Line 6), in which state is this desired bean?
        1.  Passivated
      *2. It does not exist.
        3.  Method-ready-tx
        4.  Active  
        5.  Method-ready
4. Sample Code  :
 
package testBean;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface TestHome extends EJBHome
{
           TestRemote create() throws RemoteException, CreateException;
}
 
package testBean;
import javax.ejb.*;
import java.rmi.RemoteException;
import java.rmi.Remote;
public interface TestRemote extends EJBObject
{
public void txTest(int i) throws java.rmi.RemoteException;
  Question :  After compiling the above code, what is necessary to compile stubs and skeletons?
        1 . Ejb-jar file (with manifest)     
        2 . Ejb-jar file        
        3 . The example code is fine as written. .  
      *4 . Compiled bean implementation    
        5 . Compiled client 
5. If an RMI parameter implements java.rmi.Remote, how is it passed "on-the-wire?" 
        *1.   It cannot be passed unless it ALSO implements java.io.Serializable. 
          2.   It can never be passed.   
          3.   It cannot be passed because it implements java.rmi.Remote. 
          4.   It is passed by value.      
          5.   It is passed by reference. 
6.  The ejbPassivate() method does NOT add value for which type of bean? 
        *1.   Stateless session bean    
          2.   It adds value for all beans.            
          3.   Stateful session bean 
          4.   Bean-managed persistent entity bean       
          5.   Container-managed persistent entity bean 
7.  A developer needs to deploy an Enterprise Java Bean, specifically an entity bean, but is unsure if the bean container is able to create and provide a transaction context.   Which attribute below will allow successful deployment of the bean? 
        1. Required    
      *2. Supports       
        3. RequiresNew    
        4. BeanManaged           
        5. Mandatory 
8.  The electronic bill payment application will be web-based and will allow a user to login with multiple sessions. However, the application must prevent a user from modifying his or her profile information from more than one session simultaneously with concurrent database updates.  Given the above requirement, what ACID property does this requirement represent? 
        1. Independence  
        2. Durability  
        3. Consistency
        4. Atomicity  
      *5. Isolation 
9.  Which one of the following is appropriate for an entity bean implementation? 
        1. public static final EntityContext ctx; 
        2. transient public EJBContext ctx;                                            
        3. private SessionContext ctx;               
      *4. private EntityContext ctx;             
        5. transient private EJBContext ctx; 
10.  Sample Code :
      <?xml version="1.0" encoding="Cp1252"?>
      <ejb-jar>
      <enterprise-beans>
      <session>
          <ejb-name>testBean/TestBean</ejb-name>
          <home>testBean.TestHome</home>
          <remote>testBean.TestRemote</remote>
          <ejb-class>testBean.TestBean</ejb-class>
          <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
       </session>
       </enterprise-beans>
       <assembly-descriptor>
           <container-transaction>
           <trans-attribute>RequiresNew</trans-attribute>
           </container-transaction>
        </assembly-descriptor>
     </ejb-jar>
 
Question :  Given the above vendor-specific deployment descriptor text file,  which choice below describes this bean?
        1.   The bean may execute without a transaction context.   
      *2.  The bean cannot be passivated. 
        3.   The bean will use a custom primary key.
        4.   The bean implementation class is part of the testBean package.          
        5.   The bean will be re-entrant.
11. Which of the following must the developer define in a bean-managed persistent entity bean? 
       *1. ejbPostCreate()   
        2. ejbDeactivate()   
        3. ejbPreLoad()  
        4. ejbUnsetSessionContext() 
        5. ejbSetSessionContext() 
12.   What is the first step a client must take to access an entity bean? 
        1. Execute an ejbLoad() to refresh underlying data 
        2. Execute an ejbActivate() method to prepare the bean 
        3. Access the remote object to create the home interface 
  ***4. Lookup the home interface     
        5. Execute a find method 
13.Which one of the following is the default protocol of CORBA? 
        1. JRMP  
      *2. IIOP   
        3. Not specified  
        4. TCP/IP 
        5. IDL 
14.Which one of the following SQL commands corresponds to the ejbRemove  method of a CMP entity bean? 
        1. UPDATE    
      *2. DELETE  
        3. SELECT   
        4. INSERT   
        5. REMOVE 
15.   Which one of the following isolation attributes provides the slowest performance? 
        1. TRANSACTION_READ_COMMITTED  
        2. TRANSACTION_UNREPEATABLE_READ 
      *3. TRANSACTION_SERIALIZABLE
        4. TRANSACTION_REPEATABLE_READ 
        5. TRANSACTION_READ_UNCOMMITTED 
16.    By default, what is returned from a JNDI lookup() method call when accessing an EJB? 
        1. Bean class   
        2. Entity bean   
        3. EJB handle   
      *4. Home interface           
        5. Remote interface 
17. Aside from when stateless session beans are first created, when can stateless session beans be returned to the pool? 
        1. Only after the setContext() method is called
        2. When its handle is serialized
      *3. After each method call      
        4. When its handle is garbage collected            
        5. When ejbPassivate() is called 
18. In Java2, java.security.Identity has been deprecated in favor of which one of the following? 
        1. User   
        2. UserIdentity   
        3. UserContext   
        4. SingleSignOn   
      *5. Principal 
19.  Which one of the following functions operates in a manner similar to a factory pattern, in terms of object creation? 
        1. Bean implementation  
      *2. JDBC Connection  
        3. Home interface 
        4. Client  
        5. Remote interface 
20.  In the list below, which allows the maximum degree of concurrency? 
        1. TRANSACTION_UNREPEATABLE_READ   
        2. TRANSACTION_REPEATABLE_READ 
        3. TRANSACTION_SERIALIZABLE                   
        4. TRANSACTION_READ_COMMITTED 
      *5. TRANSACTION_READ_UNCOMMITTED 
21.  What is returned by a successful InitialContext.lookup()? 
        1. InitialContext  
        2. Bean object  
        3. EJBHandle  
      *4. Reference to a home object 
        5. Reference to a remote object 
22.  Which one of the following is called first on an entity bean? 
      *1. setEntityContext()  
        2. ejbCreate()   
        3. create()   
        4. setContext()  
        5. ejbActivate() 
23.  What UserTransaction method prevents deadlock? 
      *1. setTransactionTimeout()  
        2. commit() 
        3. begin() 
        4. rollback()         
        5. getTransactionTimeout() 
24.  Which one of the following does NOT allow "phantom reads," "unrepeatable reads," or  "dirty reads?" 
      *1. TRANSACTION_SERIALIZABLE           
        2. TRANSACTION_UNREPEATABLE_READ 
        3. TRANSACTION_READ_UNCOMMITTED    
        4. TRANSACTION_READ_COMMITTED 
        5. TRANSACTION_REPEATABLE_READ 
25.   Which one of the following reduces the code necessary to enforce restrictions on bean methods executable by certain users? 
        1. Declarative authentication   
        2. Declarative authorization  
        3. Programmatic authentication 
        4. Programmatic authorization   
        5. Single sign-on 
26.   Message-queuing is well-suited for which one of the following? 
        1. Real-time processing        
        2. Streaming media          
        3. Authentication
    **4. Asynchronous method calls  
        5. Serialized method calls 
27.        Requirements  :  A bean is to be built as part of a rapid application development effort. Therefore, each   developer should write as little code as possible to ensure the integrity of the underlying data represented. 
Question : Given the above requirements, which one of the following enterprise bean types should be used? 
        1. Java bean  
    **2. BMP entity bean 
        3. Stateless session bean 
        4. CMP entity bean                                     
        5. Stateful session bean 
28.   Which one of the following enterprise beans holds NO conversational state or persistent data? 
        1. Java bean   
    **2. Stateless session bean   
        3. CMP entity bean
        4. Stateful session bean 
        5. BMP entity bean 
29.  As of EJB 1.1, which one of the following MUST be included in the finder methods
     of the home interface? 
        1. Primary key class   
        2. Transaction context  
        3. Transaction attribute 
        4. Multiple finder arrays   
        5. FinderException 
30.        Sample code  :
public class CustomPK
{
   public String custID;
           public CustomPK(String custID)
           {
      this.custID = custID;
           }
   public toString()
   {
      return custID;
              }
       } 
Question :  Using the class above as a custom primary key for an entity bean, what will be the result when attempting to compile and deploy the entity bean? 
       1. Error while generating stubs and skeletons 
       2. Compile-time error for the entity bean implementation 
       3. Compile-time error for the CustomPK class 
       4. Runtime error using the CustomPK class in a find method 
       5. No errors, the CustomPK class can be used as is. 
31.   Which one of the following Enterprise Java Beans has an ejbCreate() method with NO arguments? 
        1. BMP entity bean   
        2. Stateful session bean   
        3. CMP entity bean 
        4. Session bean with bean-managed transaction  
    **5. Stateless session bean 
31.        Sample code  :
1. InitialContext ic = new InitialContext();
2. Object o = ic.lookup("testBean/TestBean");
3. // Bean status?
4. TestHome th = (TestHome)javax.rmi.PortableRemoteObject.narrow(o,TestHome.class);
5. String result = myTest.userMethod();
6. myTest.remove(); 
Question : Assume the application server has just been started. At the commented-marker in the client code above (Line 3), in which state is this desired bean? 
        1. Method-ready-tx   
        2. It does not exist.  
        3. Method-ready 
        4. Passivated 
        5. Active 
33. Which one of the following objects provides the lookup() method? 
    **1. InitialContext   
        2. javax.ejb.Remote  
        3. EJBHome  
        4.EJBObject   
        5.EJBContext 
34. Which one of the following is the only method specified in the EJBObject interface that does not return a value or object? 
        1. getHandle() 
  *** 2. remove()  
        3. isIdentical() 
        4. getPimaryKey() 
        5. getEJBHome() 
35. Declarative security in EJB 1.1 is provided by which one of the following? 
        1. Operating-system specific environment 
        2. ACLs provided in a Java properties file 
*** 3. ACLs in the deployment descriptor 
        4. ACLs in the bean implementation 
        5. Single-signon vendors 
36. Which one of the following is NOT supported in the EJB 1.1 specification? 
        1. Transaction status callbacks 
        2. Transaction level deployment descriptors                          
        3. Container-managed transactions 
  ***4. Bean-managed transactions 
        5. Nested transactions 
37. Sample code
<?xml version="1.0" encoding="Cp1252"?>
<ejb-jar>
     <enterprise-beans>
       <session>
<ejb-name>testBean/TestBean</ejb-name>
<home>testBean.TestHome</home>
<remote>testBean.TestRemote</remote>
<ejb-class>testBean.TestBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
       </session>
     </enterprise-beans>
     <assembly-descriptor>
       <container-transaction>
<trans-attribute>Supports</trans-attribute>
       </container-transaction>
     </assembly-descriptor>
   </ejb-jar> 

Given the above vendor-specific deployment descriptor text file, what is the best
   choice describing the behavior of this bean? 
1. This bean may execute without a transaction context. 
2. This bean will be re-entrant. 
3. The bean will be forced to passivate after ten seconds. 
4. The bean will use a custom primary key. 
5. The bean implementation class is not part of a package. 
38. Which one of the following choices represents an optional file that may be included in an ejb-jar file to list the contents? 
        1. Serialized object  
        2. Deployment description 
        3.Class file 
  ***4. Manifest 
        5. EJB context 
39. What is the benefit of a "coarse grained" entity bean in a distributed environment? 
        1. Interface is coupled with implementation 
        2. Less code to implement         
        3. Reduced network traffic 
  ***4.  Reduced number of clients
        5. Allows nested transactions
Hosted by www.Geocities.ws

1