jQuery in Action, 2nd edition*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Long Awaited - Answers to batches #2, #3, #11 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Long Awaited - Answers to batches #2, #3, #11" Watch "Long Awaited - Answers to batches #2, #3, #11" New topic
Author

Long Awaited - Answers to batches #2, #3, #11

Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
Answers to EJB Mock fodder questions:
New disclaimer: A few *refinements* (OK, errors), were found in these questions. I'll fall on my sword here, sorry. But at least you had the *learning experience* of understanding the topics well enough to spot the *refinements* !
Fixes to the questions will be noted with << >> marks

Old Disclaimers:
You WON'T get any questions on the real exam that say 'choose all that apply' - you will always know exactly how many answers are correct. I use 'choose all that apply' to make these questions harder, you know, to toughen you up a bit
When I say 'choose all that apply', there will ALWAYS be at least one correct answer.
The real exam uses several forms of 'drag and drop' which I'm kind of pseudo-emulating here; read the questions carefully, for instance some are one-to-many, some are not!
Finally, remember the real exam is NOT open-book
End of disclaimers, and on to the questions:
=======================================================
EJB Mock Exam #2
2.1 Which statement about session beans is true?
a). The bean provider must write the method public void remove() in both stateless and stateful session classes.
b). Local clients can remove session beans by calling a method on the bean's home.
c). The << remove >> method in the component interface can be used only by remote clients.
d). To ask the EJBHome to remove a session bean, the client must provide the bean's handle.
Answer: d
revision: 2c was << ejbRemove >>
2.2 Which statement about locating or using a session bean's home interface is true?
a). Acquiring an 'InitialContext' is required only for remote clients.
b). The 'InitialContext' must be narrowed before it can be used.
c). Once acquired by a client, a home interface can be used multiple times.
d). The client can acquire a handle for the bean's local home interface.
Answer: c
2.3 When comparing two session objects, what is true? (Choose all that apply.)
a). Using the 'isIdentical' method, stateless session beans from the same home will always return true.
b). Using the 'isIdentical' method, stateful session beans from the same home will always return true.
c). The 'isIdentical' method can be used only for remote object references.
d). Using the 'equals' method, stateless session beans from the same home will always return true.
e). Using the 'equals' method, stateful session beans from the same home will always return true.
Answer: a
2.4 Which method can be called << without exception >>, by both remote and local clients on a reference to a session bean's component interface?
a). ejbCreate
b). getSessionContext
c). getPrimaryKey
d). getEJBHome
e). remove
Answer: e
revision: added 'without exception'

=======================================================
EJB Mock Exam #3
3.1 Which are directly invoked by the client? (Choose all that apply.)
a). ejbPassivate
b). business methods
c). setSessionContext
d). newInstance
e). create
Answer: b, e

3.2 Which is true about passivation for stateful session beans?
a). The container can passivate a stateful session bean regardless of the bean's << transactional >> state.
b). The client can passivate a session bean.
c). References to JNDI contexts are lost during passivation.
d). References to 'SessionContext' are preserved during passivation.
e). A passivated, stateful session bean instance will always be re-activated prior to removal.
Answer: d
revision: 3.2.a - added << transactional >>

3.3 (Note: The real exam has several types of 'drag and drop' questions, that I'm going to do a lame job of simulating with this question...)
Match the methods on the left with the interfaces in which those methods can be found, on the right. A match is correct if the method is either declared in, or inherited by, the interface. Note: There may be some many-to-one and one-to-many relationships in your answer.

Answers:
a - 1
b - 2
c - 1
d - 2
e - 2
f - 3
<< answer for new method g - 2,4 >>
revision: added a new method

3.4 Which statements about stateful and stateless session beans are true?
(Choose all that apply.)
a). Only stateful session beans support transactions.
b). Only stateful session beans can be passivated.
c). Only stateful session beans have a 'setSessionContext' method.
d). Both stateful and stateless session beans can support overloaded 'ejbCreate' methods.
e). Both stateful and stateless session beans can implement the 'javax.ejb.SessionSynchronization' interface.
f). Both stateful and stateless session beans can have instance variable state.
Answer: b, f
3.5 Which statements about a session bean class are true? (Choose all that apply.)
a). They can be marked 'final'
b). They can support overloaded constructors.
c). Their business methods can be 'private'.
d). Their business method names must start with "ejb".
e). Their 'ejbCreate' methods must not be declared as 'final'.
Answer: e

3.6 For this drag and drop type question, you can use each element only once. Which interface should be matched with which fact, so that all four matches are correct?

Answers:
1 - b
2 - d
3 - a
4 - c

=================================================
11.1 Which two are true about container managed transactions in EJB 2.0? (Choose all that apply.)
a). Differentiating between overloaded methods is possible in the bean's deployment descriptor.
b). A transactional attribute must be individually declared in the method-name tag, for every business method in the bean class.
c). The container will interpose only on method invocations with container-managed transaction demarcation.
d). If an 'onMessage' method returns before committing a transaction the container will throw an exception.
e). A message-driven bean with CMT demarcation must not invoke the EJBContext.getUserTransaction method.

Answers: a, e

11.2 When a business method in an entity bean calls the getRollbackOnly method, which transaction attribute settings will cause the container to throw an exception? (Choose all that apply.)
a). NotSupported
b). Required
c). Supports
d). RequiresNew
e). Mandatory
f). Never
Answers: a, c, f
11.3 When a session bean has container-managed demarcation value of 'Supports', which << three >> methods run in an unspecified transaction context? (Choose << three >>.)
a). ejbActivate
b). getRollbackOnly
c). getUserTransaction
d). ejbRemove
e). afterBegin
f). afterCompletion
Answers: a, d, f
revision: changed 'two' to 'three'

===============================================

If you can stand it, I'll try to post batch #12, soon. (And I promise the answers will be more timely )
[ June 05, 2003: Message edited by: Bert Bates ]

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Kalpesh Soni
Ranch Hand

Joined: Jan 02, 2001
Posts: 312
correction
3.6
answers
1 - b was fine
2 - d was fine
3 - c
4 - a
Kalpesh Soni
Ranch Hand

Joined: Jan 02, 2001
Posts: 312

11.2 When a business method in an entity bean calls the getRollbackOnly method, which transaction attribute settings <<<will>>> cause the container to throw an exception?

if
trans-attribute is supports
but this business method is called when transaction is already started
call getRollbackOnly() or setRollbackOnly()
and it <<will not>> throw IllegalStateException
[ June 06, 2003: Message edited by: Kalpesh Soni ]
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8883
    
    5
Kalpesh -
I think both are OK...
sh yh
Greenhorn

Joined: Aug 14, 2002
Posts: 21
Originally posted by Kalpesh Soni:
correction
3.6
answers
1 - b was fine
2 - d was fine
3 - c
4 - a

I think both 3c/4a and 3a/4c are ok.
sh yh
Greenhorn

Joined: Aug 14, 2002
Posts: 21
Originally posted by Bert Bates:
Answers to EJB Mock fodder questions:
11.3 When a session bean has container-managed demarcation value of 'Supports', which << three >> methods run in an unspecified transaction context? (Choose << three >>.)
a). ejbActivate
b). getRollbackOnly
c). getUserTransaction
d). ejbRemove
e). afterBegin
f). afterCompletion
Answers: a, d, f
revision: changed 'two' to 'three'

===============================================

I would suggest to reword the question by replacing "...run..." as "...will always run..." in order to eliminate confusions such as, for example, afterBegin() COULD also run in an unspecified transaction context.
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Can somebody please explain step by step how to go about this type of questions?
--------------------------------------------------------------------------------
3.6 For this drag and drop type question, you can use each element only once. Which interface should be matched with which fact, so that all four matches are correct?

1. remote component --- a. does not have a getHomeHandle() method
2. remote home --- b. extends 'javax.ejb.EJBObject'
3. local component --- c. methods must NOT throw 'java.rmi.RemoteException'
4. local home --- d. can be used to retrieve an EJBObject reference.
1 - b
2 - d
3 - a
4 - c
--------------------------------------------------------------------------------
For example: what does 4-C mean? Does it mean that I can get a EJBObject reference from EJBLocalHome?
My answers are:
1 - ABD
2 - none
3 - AC
4 - AC
but "...each element only once...".
Please clarify!
+Seid
[ June 06, 2003: Message edited by: Seid Myadiyev ]

Seid Myadiyev<br />SCJP, SCWCD, SCBCD, SCEA-Part 1
Seid Myadiyev
Ranch Hand

Joined: Jul 02, 2002
Posts: 196
Hello Andrew,
Thank very very much for your detailed account of your exam experience! It is really helpful!
Andrew, may I please ask your help in clearing my question above. There is something I am missing and I do not know what exactly!
Thank you so much in advance!
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
3.2 Which is true about passivation for stateful session beans?

a). The container can passivate a stateful session bean regardless of the bean's << transactional >> state.
b). The client can passivate a session bean.
c). References to JNDI contexts are lost during passivation.
d). References to 'SessionContext' are preserved during passivation.
e). A passivated, stateful session bean instance will always be re-activated prior to removal.

Answer: d
revision: 3.2.a - added << transactional >>


I don't understand this. How does the SessionContext reference is preserved during passivation? The spec (page 72) says that 'container must be able to save and restore the reference across instance's passivation.

Can someone please help me understand this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Long Awaited - Answers to batches #2, #3, #11