nerdexam
Oracle

1Z0-895 · Question #81

Given Singleton bean FooEJB: FooEJB is packaged as the only bean in an ejb-jar and deployed to a server instance. Which represents the output generated from FooEJB after the deployment has completed?

The correct answer is A. Init. The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization. This method MUST be invoked before the class is put into service. This annotation MUST be supported on all classes that support…

Session Beans

Question

Given Singleton bean FooEJB: FooEJB is packaged as the only bean in an ejb-jar and deployed to a server instance. Which represents the output generated from FooEJB after the deployment has completed?

Exhibit

1Z0-895 question #81 exhibit

Options

  • AInit
  • Bfoo
  • CInit foo
  • D<no output>
  • Ea or d

How the community answered

(21 responses)
  • A
    81% (17)
  • C
    5% (1)
  • D
    10% (2)
  • E
    5% (1)

Explanation

*The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization. This method MUST be invoked before the class is put into service. This annotation MUST be supported on all classes that support dependency injection. The method annotated with PostConstruct MUST be invoked even if the class does not request any resources to be injected. Only one method can be annotated with this annotation. The method on which the PostConstruct annotation is applied MUST fulfill all of the following criteria - - The method MUST NOT have any parameters except in the case of EJB interceptors in which case it takes an InvocationC ontext object as defined by the EJB specification. - The return type of the method MUST be void. - The method MUST NOT throw a checked exception. - The method on which PostConstruct is applied MAY be public, protected, package private or private. - The method MUST NOT be static except for the application client. - The method MAY be final. - If the method throws an unchecked exception the class MUST NOT be put into service except in the case of EJBs where the EJB can handle exceptions and even recover from them. *PostConstruct methods are invoked on the newly constructed instance, after any dependency injection has been performed by the container and before the first businessmethod is invoked on

Topics

#singleton session bean#@PostConstruct#startup initialization#bean lifecycle

Community Discussion

No community discussion yet for this question.

Full 1Z0-895 Practice