Multiple choice java

For a stateful session bean, which method is activated by the container to save the state of the bean?

  1. ejbCreate()

  2. ejbPassivate()

  3. ejbStore()

  4. ejbSave()

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

For stateful session beans, ejbPassivate() serializes the bean to secondary storage (temporarily saving it), and ejbActivate() restores it. However, ejbStore() is the method that explicitly saves the bean's state to persistent storage during passivation or before container shutdown. ejbCreate() (A) is for initialization, not saving state. ejbPassivate() (B) triggers the passivation process but ejbStore() does the actual saving work. ejbSave() (D) doesn't exist in the EJB API.