GSSP-JAVA · Question #113
Mark works as a Programmer for InfoTech Inc. He develops the following code snippet. package Mark.tutorial.javaee.ejb; import java.util.logging.Logger; import javax.annotation.Resource; import…
The correct answer is B. The EJB container will invoke the timeout method of TimerSessionBean when the timer D. TimerBean is a stateless session bean that shows how to set a timer. See the full explanation below for the reasoning.
Question
Mark works as a Programmer for InfoTech Inc. He develops the following code snippet. package Mark.tutorial.javaee.ejb; import java.util.logging.Logger; import javax.annotation.Resource; import javax.ejb.Stateless; import javax.ejb.Timeout; import javax.ejb.Timer; import javax.ejb.TimerService; @Stateless public class TimerBean implements TimerSessionBean { @Resource TimerService timerService; private static final Logger logger = Logger.getLogger ("com.sun.tutorial.javaee.ejb.timersession.TimerSessionBean"); public void createTimer(long intervalDuration) { Timer timer = timerService.createTimer(intervalDuration, "New timer created"); } @Timeout public void timeout(Timer timer) { logger.info("Timer Timeout"); } } Which of the following statements are true about the code? Each correct answer represents a complete solution. Choose all that apply.
Options
- AThe class Logger cannot be used with a stateless session bean.
- BThe EJB container will invoke the timeout method of TimerSessionBean when the timer
- CThe class is using the createTimer method incorrectly because it creates a new timer.
- DTimerBean is a stateless session bean that shows how to set a timer.
How the community answered
(25 responses)- A8% (2)
- B84% (21)
- C8% (2)
Community Discussion
No community discussion yet for this question.