EJB Interview Questions and Answers


1)A developer successfully creating and tests a stateful bean following deployment, intermittent
"NullpointerException" begin to occur, particularly when the server is hardly loaded. What most likely to
related problem.
a) setSessionContext     b) ejbCreate       c) ejbPassivate  d) beforeCompletion    e) ejbLoad

2)2 example implementations os Proxy are RMI & EJb

3)If an RMI parameter implements java.rmi.Remote, how is  it passed "on-the-wire?" 
 Choice 1   :     It can never be passed. 
 Choice 2   :     It is passed by value. 
 Choice 3   :     It cannot be passed because it implements  java.rmi.Remote. 
 Choice 4   :      It cannot be passed unless it ALSO implements  java.io.Serializable. 
 Choice 5    :      It is passed by reference.           ans)2
  4)public synchronized void  txTest(int i)  {
                        System.out.println("Integer is: " + i);    } 
   What is the outcome of attempting to compile and  execute the method above, assuming it is implemented
 in a stateful session bean? 
 Choice 1  :   Run-time error when bean is created 
 Choice 2  :    The method will run, violating the EJB specification.
  Choice 3  :   Compile-time error for bean implementation class 
 Choice 4   :    Compile-time error for remote interface 
 Choice 5   :     Run-time error when the method is executed             ans)2
 
 5)What is the CORBA naming service equivalent of JNDI? 
 Choice 1  :      Interface Definition Language 
 Choice 2   :     COS Naming 
 Choice 3   :      Lightweight Directory Access Protocol 
 Choice 4   :        Interoperable Inter-Orb Protocol 
 Choice 5  :         Computer Naming Service                     ans)2 

 6)InitialContext ic = new InitialContext();
 TestHome th = (TestHome)
 ic.lookup("testBean/TestBean");
 TestRemote beanA = th.create();
 TestRemote beanB = th.create();
 TestRemote beanC = th.create();
 beanC.remove();
 TestRemote beanD = th.create();
 TestRemote beanE = th.create();
 beanC = th.create(); 
   Given the above code, container passivates which  bean instance first if the container limited the bean  pool size to four beans and used a  "least-recently-used" algorithm to passivate? 
 Choice 1 :      Bean A 
 Choice 2  :     Bean B 
 Choice 3  :     Bean C 
 Choice 4  :     Bean D 
 Choice 5  :     Bean E 
  
 7)Which one of the following phenomena is NOT addressed  by   read-consistency?
 A.Phantom read    b.Cached read    c.Dirty read   d.Non-repeatable read    e.Fuzzy read  ans)b,e

 8)Which one of the following methods is generally called  in both   ejbLoad() and ejbStore()?
 a getEJBObject()   b getHandle()    c remove()   d getEJBHome()   e getPrimaryKey()  ans)e

 9)public void ejbCreate(int i) {
         System.out.println("ejbCreate(i)");   }
  Given a currently working stateless session bean, what  will be the outcome   upon deploying and executing the bean if you added the  above unique method   to the implementation class of a  stateless session  bean (and made no other   changes)?
 a Compile time error during stub/skeleton generation
 b Compile time error for home interface
 c Code will compile without errors.
 d Compile time error for remote interface
 e Compile time error for bean implementation              ans)a

 10)Given the above code in your stateless session bean  business method   implementation, and the transaction is  container-managed with a Transaction   Attribute of TX_SUPPORTS, which one of the following  is the first error   generated?
 a Error when compiling home interface
 b Error while generating stubs and skeletons
 c NullPointerException during deployment
 d Runtime error
 e Compile-time error for the bean implementation            ans)b

 11)Which one of the following is the result of attempting  to deploy a   stateless session bean and execute one of the method M  when the bean   implementation contains the method M NOT defined in  the remote interface?
 a Compile time error for remote interface
 b Compile time error for bean implementation
 c Compile time error during stub/skeleton generation
 d Code will compile without errors.
 e Compile time error for home interface          ans)d
  12)Which one of the following characteristics is NOT true  of RMI and   Enterprise Java Beans?
 a They must execute within the confines of a Java  virtual machine (JVM).
 b They serialize objects for distribution.
 c They require .class files to generate stubs and  skeletons.
 d They do not require IDL.
 e They specify the use of the IIOP wire protocol for  distribution.            ans)a

13. Which one of the following is the result of attempting to deploy a  stateless session bean and execute one of the method M when the bean  implementation contains the method M NOT defined in the remote interface?
a Compile time error for remote interface
b Compile time error for bean implementation
c Compile time error during stub/skeleton generation
d Code will compile without errors.
e Compile time error for home interface
14. If a unique constraint for primary keys is not enabled in a database,  multiple rows of data with the same primary key could exist in a table.  Entity beans that represent the data from the table described above are  likely to throw which exception?
a NoSuchEntityException
b FinderException
c ObjectNotFoundException
d RemoveException
e NullPointerException

15. 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?
a BeanManaged
b RequiresNew
c Mandatory
d Required
e Supports

16. What is the outcome of attempting to compile and execute the method  above, assuming it is implemented in a stateful session bean?
a Compile-time error for remote interface
b Run-time error when bean is created
c Compile-time error for bean implementation class
d The method will run, violating the EJB specification.
e Run-time error when the method is executed

17. Which one of the following is the result of attempting to deploy a  stateless session bean and execute one of the method M when the bean  implementation contains the method M NOT defined in the remote interface?
a Compile time error for remote interface
b Compile time error for bean implementation
c Compile time error during stub/skeleton generation
d Code will compile without errors.
e Compile time error for home interface
18. If a unique constraint for primary keys is not enabled in a database,  multiple rows of data with the same primary key could exist in a table. Entity beans that represent the data from the table described above are  likely to throw which exception?
a NoSuchEntityException
b FinderException
c ObjectNotFoundException
d RemoveException
e NullPointerException

19. There are two Enterprise Java Beans, A and B. A method in "A" named  "Am" begins execution, reads a value v from the database and sets a variable "X" to value v, which is one hundred. "Am" adds fifty to the variable X and  updates the database with the new value of X. "Am" calls "Bm", which is a method in B. "Bm" begins executing. "Bm" reads an additional value from the database. Based on the value, "Bm" determines that a business rule has been  violated and aborts the transaction. Control is returned to "Am".Requirement: If "Bm" aborts the transaction, it is imperative that the original value be  read from the database and stored in variable X.

Given the scenario above, which Transaction Attributes will most likely meet  the requirements stated?
a A-RequiresNew,   B-Mandatory
b A-Mandatory,       B-RequiresNew
c A-RequiresNew,   B-Supports
d A-NotSupported,  B-RequiresNew
e A-RequiresNew,   B-RequiresNew

20.) If an RMI parameter implements java.rmi.Remote, how is it passed "on-the-wire?" 
Choice 1  : It can never be passed. 
Choice 2  : It is passed by value. 
Choice 3   : It cannot be passed because it implements java.rmi.Remote. 
Choice 4   : (Correct) It cannot be passed unless it ALSO implements java.io.Serializable. 
Choice 5   : It is passed by reference. 

21.) public synchronized void  txTest(int i)  {
          System.out.println("Integer is: " + i);   } 
  What is the outcome of attempting to compile and   execute the method above, assuming it is implemented in a stateful session bean? 
Choice 1  :   Run-time error when bean is created 
Choice 2  :   The method will run, violating the EJB specification.
Choice 3   :  (Correct) Compile-time error for bean implementation class 
Choice 4   :  Compile-time error for remote interface 
Choice 5  :   Run-time error when the method is executed 

22.) What is the CORBA naming service equivalent of JNDI? 
Choice 1  :  Interface Definition Language 
Choice 2  :  (Correct) COS Naming 
Choice 3  :  Lightweight Directory Access Protocol 
Choice 4  :  Interoperable Inter-Orb Protocol 
Choice 5  :   Computer Naming Service 



InitialContext ic = new InitialContext();
TestHome th = (TestHome)
ic.lookup("testBean/TestBean");
TestRemote beanA = th.create();
TestRemote beanB = th.create();
TestRemote beanC = th.create();
beanC.remove();
TestRemote beanD = th.create();
TestRemote beanE = th.create();
beanC = th.create(); 
  Given the above code, container passivates which bean instance first if the container limited the bean pool size to four beans and used a "least-recently-used" algorithm to passivate? 
Choice 1  
Bean A 
Choice 2  
Bean B 
Choice 3  
Bean C 
Choice 4  (Correct, Since only Statefull session bean and Entity Bean can be passivated, and Entitybean can not call as th.create() normally, I take it as statefull session bean)
Bean D 
Choice 5  
Bean E 

-------------------------

Which one of the following phenomena is NOT addressedby read-consistency?
a Phantom read (Correct)
b Cached read
c Dirty read
d Non-repeatable read
e Fuzzy read

--------------------------

Which one of the following methods is generally called
in both
ejbLoad() and ejbStore()?
a getEJBObject()
b getHandle()
c remove()
d getEJBHome()
e getPrimaryKey() (Correct)


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email