• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

More Mock Questions Here

 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few more...
Here's my attempt at a *matching* drag-and-drop question. These are off the top of my head again, so I can't guarantee they're perfect
============================
QUESTION ONE:
Match the operation in list ONE with the method in list TWO in which that operation can be performed, for a stateful session bean:
LIST ONE: Operations (things you want to do)
1) invoke the SessionContext.setRollbackOnly()
2) invoke the UserTransaction.setRollbackOnly()
3) access this bean's own EJBObject interface
4) access this bean's own home interface
5) access a reference to another EJB

LIST TWO: Bean methods in which the operations from list one can be performed:
A) ejbCreate
B) afterBegin
C) business method
D) setSessionContext
E) afterCompletion
Note: There *may* be more than one correct answer!
===========================

QUESTION TWO:
In what order will the following events in a stateful session bean's lifecycle occur? Assume the client already has a reference to a bean's home object, and needs to invoke a business method on a bean.
(place a number next to each one)
A) Client invokes a business method
B) ejbCreate invoked on the bean
C) transaction committed
D) afterCompletion is called
E) afterBegin is called
F) beforeCompletion is called
G) business method invoked on the bean
H) setSessionContext invoked on the bean
I) bean constructor invoked
J) client invokes create on the home
=========================
cheers,
Kathy
 
Andrew Perepelytsya
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Q2, I would place it as follows:
1. J) client invokes create on the home
2. I) bean constructor invoked
3. H) setSessionContext invoked on the bean
4. B) ejbCreate invoked on the bean
5. A) Client invokes a business method
6. E) afterBegin is called
7. G) business method invoked on the bean
8. F) beforeCompletion is called
9. C) transaction committed
10.D) afterCompletion is called
My only doubt for this question (kewl one ) was the afterBegin() method. Well, the spec is out there for it, and yes, it is actually called before any business method invoked on the bean.
Will dig for Q1 info, this one requires deep knowledge of the internals. Required for the exam, good (but not strictly required) in real-life.
 
Dragan Milic
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kathy Sierra:
QUESTION ONE:
Match the operation in list ONE with the method in list TWO in which that operation can be performed, for a stateful session bean:
LIST ONE: Operations (things you want to do)
1) invoke the SessionContext.setRollbackOnly()
2) invoke the UserTransaction.setRollbackOnly()
3) access this bean's own EJBObject interface
4) access this bean's own home interface
5) access a reference to another EJB

LIST TWO: Bean methods in which the operations from list one can be performed:
A) ejbCreate
B) afterBegin
C) business method
D) setSessionContext
E) afterCompletion
Note: There *may* be more than one correct answer!

Ok, i hope i won't mess up this time
1 - B,C (May be called only if there is a transaction context and CMT is used).
2 - A,C (B is not possible since BMT does not support SessionSynchronization interface)
3 - A,C or A,B,C,E depending on Transaction management BMT or CMT (according to the spec there is no SFSB identity at the time the method setSessionContext() is called)
4 - A,C,D or A,B,C,D,E also depending on transaction management BMT/CMT: You can always (Except in the bean constructor) access the EJBHome.

5 - A,C or A,B,C (BMT/CMT): In the afterCompletion() method there is no transactional context, setSessionContext() has no caller identity.
Dragan
 
Kalpesh Soni
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kathy ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic