Oracle
1Z0-895 · Question #22
A developer writes a stateful session bean FooBean with one remote business interface Foo. Foo defines an integer / setter method pair implemented as: 10. private int value; 11. public void setValue…
The correct answer is D. Foo1.getValue () = = 1 and foo2.getValue() = = 1. Foo1 and Foo2 references the same object.
Performance Tuning
Question
A developer writes a stateful session bean FooBean with one remote business interface Foo. Foo defines an integer / setter method pair implemented as: 10. private int value; 11. public void setValue (int i) {value = i; } 12. public int getValue () {return value; } A session bean ClientBean has a business method doSomething and an ejb-ref with ejb-ref-name "fooRef" that is mapped to FooBean's Foo interface. 11. @Resource private SessionContext SessionCtx; 12. public void doSomething () { 13. Foo foo1 = (Foo) sessionCtx.lookup("fooRef"); 14. Foo foo2 = (Foo) sessionCtx.lookup("fooRef"); 15. foo1.setvalue(1); Which statement is true after the code at line 15 completes?
Options
- AFoo1.getValue () = = 0 and foo2.getValue() = = 0
- BFoo1.getValue () = = 0 and foo2.getValue() = = 1
- CFoo1.getValue () = = 1 and foo2.getValue() = = 0
- DFoo1.getValue () = = 1 and foo2.getValue() = = 1
How the community answered
(27 responses)- A4% (1)
- B7% (2)
- C15% (4)
- D74% (20)
Explanation
Foo1 and Foo2 references the same object.
Topics
#stateful session bean#ejb-ref#bean identity#state isolation
Community Discussion
No community discussion yet for this question.