nerdexam
Oracle

1Z0-900 · Question #15

: 15 Given: What code needs to be added to line 1 for MyMapper bean instances to be correctly passivated?

The correct answer is D. @Stateful. @Stateful is correct because passivation - the process of serializing a bean's conversational state to secondary storage when idle - is a capability exclusive to stateful session beans. The EJB container automatically manages passivation and activation for @Stateful beans…

Implement Business Logic by Using EJBs

Question

: 15 Given:

What code needs to be added to line 1 for MyMapper bean instances to be correctly passivated?

Options

  • A@Stateless @PassivationCapable
  • B@Stateless
  • C@Stateful @PassivationCapable
  • D@Stateful

How the community answered

(23 responses)
  • A
    4% (1)
  • B
    17% (4)
  • C
    4% (1)
  • D
    74% (17)

Explanation

@Stateful is correct because passivation - the process of serializing a bean's conversational state to secondary storage when idle - is a capability exclusive to stateful session beans. The EJB container automatically manages passivation and activation for @Stateful beans without requiring any additional annotation.

@Stateless (options A and B) is wrong because stateless session beans hold no conversational state between calls, so there is nothing to passivate. @PassivationCapable in options A and C is a red herring - it is a CDI interface (javax.enterprise.inject.spi.PassivationCapable), not a standard EJB annotation that enables or is required for passivation. Adding it alongside @Stateful (option C) is therefore redundant and incorrect for this context.

Memory tip: Think "Stateful = State to save." Passivation only makes sense when there is conversational state worth preserving - that's always @Stateful, and @Stateful alone is sufficient.

Topics

#EJB passivation#Stateful beans#Bean lifecycle#State management

Community Discussion

No community discussion yet for this question.

Full 1Z0-900 Practice