File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Mock Questions: transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Mock Questions: transactions" Watch "Mock Questions: transactions" New topic
Author

Mock Questions: transactions

Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Q1: Which three are true about transactions in EJB?
(Choose three.)
A) EJB 2.0 supports nested transactions.
B) EJB 2.0 allows you to specify isolation levels.
C) Message-driven beans must not use bean-managed transaction demarcation.
D) Entity beans must not use bean-managed transaction demarcation.
E) Stateful session bean state will not be rolled back if the transaction rolls back.
F) Stateful session beans that start a transaction must complete the transaction before ending a business method.
G) A message-driven bean must commit or rollback a transaction before onMessage returns.
==============================
Q2: Which two are true about bean-managed transaction demarcation?
A) A transaction used by a BMT bean MUST have been started by the bean.
B) The caller's transaction will be propogated into a BMT bean.
C) Transactions in a BMT bean do not propogate when the BMT bean calls a method on another bean.
D) A bean cannot use both CMT and BMT together.
E) BMT beans must not specify transaction attributes.
============================
OK, get your brain in gear
cheers,
Kathy
(tomorrow, I'm putting up some HARDER transaction questions )
Dragan Milic
Ranch Hand

Joined: Oct 03, 2002
Posts: 31
Hi Kathy,
Originally posted by Kathy Sierra:
Q1: Which three are true about transactions in EJB?
(Choose three.)
A) EJB 2.0 supports nested transactions.
B) EJB 2.0 allows you to specify isolation levels.
C) Message-driven beans must not use bean-managed transaction demarcation.
D) Entity beans must not use bean-managed transaction demarcation.
E) Stateful session bean state will not be rolled back if the transaction rolls back.
F) Stateful session beans that start a transaction must complete the transaction before ending a business method.
G) A message-driven bean must commit or rollback a transaction before onMessage returns.


IMO The Answer is C, D and G.
A - EJB 2.0 supports no nested transactions (see ejb 2.0 spec 17.1.2)
B - EJB 2.0 specify no isolaton leves (17.3.2 in the spec)
C - MDBs can use BMT, but must commit or rollback the transaction before returning from the onMessage() method (17.3.3).
D - Only MDB and Session Beans can use BMT (17.3.3)
E - It would be very expensive to implement such behavior in the container - The session should be passivated and stored on the start of the transaction, and reactivated on rollback - that would be a major performance killer ... also the SessionSynchronization interface would not make much sense.
F - SFSB can start a Transaction in one and end it in another business method, SLSB must end the transaction in the same business method.
G - It would not make sense to leave the transaction unfinished, MDB can be seen as a special case of a SLSB where the method invocator is a queue or a topic. See also (17.3.3). BTW This possibility is a bit vague, in the case of the CMT the MDB cannot commit or rollback the transaction (it can only mark it as rollback only or throw the EJB Exception)



Q2: Which two are true about bean-managed transaction demarcation?
A) A transaction used by a BMT bean MUST have been started by the bean.
B) The caller's transaction will be propogated into a BMT bean.
C) Transactions in a BMT bean do not propogate when the BMT bean calls a method on another bean.
D) A bean cannot use both CMT and BMT together.
E) BMT beans must not specify transaction attributes.

A, D, E
A - Since the bean manages the transactions, it must also start them.
B - That would be a conflict with the 17.1.2 - nested transactions are not supported by EJB 2.0
C - BMT and CMT are threated equally when a method on another bean is called (this option is also vague, the caller's transaction will will be suspended if the business method on another specifies RequiresNew or NotSupported transaction attribute)
D - It is not possible to define CMT or BMT on method basis - only for the whole bean
E - transaction attributes are specified only for CMT, see 17.3.6 and 17.4.1

BTW Kathy, 10x for investing your time and energy in our cert preparation, you are doing a great job!
Dragan
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Answer for first one D,E AND G.
2nd one E and D.
[ May 26, 2003: Message edited by: Pradeep Bhat ]
[ May 26, 2003: Message edited by: Pradeep Bhat ]

Groovy
Dragan Milic
Ranch Hand

Joined: Oct 03, 2002
Posts: 31
Originally posted by Pradeep Bhat:
Answer for first one D,E AND G.

You are right, I forgot to change C in E after re-reading the chapter 17 of the spec.
Dragan
[ May 26, 2003: Message edited by: Dragan Milic ]
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
Oops... I said "which two" in question two, when there are THREE correct answers... good thing Dragan gave the correct answer anyway
Good job Dragan and Pradeep! And Dragan, specifying your explanation / reasoning on the answers is extremely helpful to everyone... so thank-you.
cheers,
Kathy
Kalpesh Soni
Ranch Hand

Joined: Jan 02, 2001
Posts: 312
what happens if client starts the transaction and calls a method of SLSB/SFSB with BMT , if....
1) the called method starts transaction and accessed db
2) the called method does not have any transaction logic, but accessed db, jms destination etc.
[ June 05, 2003: Message edited by: Kalpesh Soni ]

Test 094, IBM WID 6.0 cert
SCJP 1.2
SCBCD 1.3 Beta
SCWCD 1.4 Beta
SCMAD Beta
SCDJWS Beta

KS
Bob Walker Jr
Ranch Hand

Joined: Jun 02, 2003
Posts: 46
So what are the final answers?
Why is 'a' correct for question 2?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Questions: transactions
 
Similar Threads
a mock question about transcation
BMT Mock question
Mock Exam Question
BMT problem
Doubts in Mock exam questions.