Which statement is true after the code at line 15 completes?

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 FooBeans 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?

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 FooBeans 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?

A.
Foo1.getValue () = = 0 and foo2.getValue() = = 0

B.
Foo1.getValue () = = 0 and foo2.getValue() = = 1

C.
Foo1.getValue () = = 1 and foo2.getValue() = = 0

D.
Foo1.getValue () = = 1 and foo2.getValue() = = 1

Explanation:
Foo1 and Foo2 references the same object.



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Figaro

Figaro

It’s stateful session bean so only answer C is correct

Andrei

Andrei

For Stateful Session bean foo1.equals(foo2) always false.

JavaBatman

JavaBatman

People you all wrong its D