nerdexam
Oracle

1Z0-895 · Question #34

A developer writes a stateful session bean FooBean with two local business interfaces Foo and bar. The developer wants to write a business method called getBar for interface Foo that returns a Bar…

The correct answer is D. Return (bar) sessionCtx.getBusinessObject(Bar.class). See the full explanation below for the reasoning.

Question

A developer writes a stateful session bean FooBean with two local business interfaces Foo and bar. The developer wants to write a business method called getBar for interface Foo that returns a Bar reference to the same session bean identity on which the client onvokes getBar. Which code, when inserted on line 12 below implements the getBar method with the wanted behavior? 10. @Resource SessionContext sessionCtx; 11. public Bar getbar () { 12. 13. }

Options

  • AReturn (bar) this;
  • BReturn (bar) new FooBarBean();
  • CReturn (bar) sessionCtx.lookup("FooBarBean")
  • DReturn (bar) sessionCtx.getBusinessObject(Bar.class);
  • EReturn (bar) session Ctx.lookup("java: comp/env/ejb/FooBarBean");

How the community answered

(24 responses)
  • A
    4% (1)
  • B
    8% (2)
  • D
    75% (18)
  • E
    13% (3)

Community Discussion

No community discussion yet for this question.

Full 1Z0-895 Practice