Which three statements are true?

Given the following client-side code that makes use of the session bean Foo:
10. @EJB Foo bean1;
12. @EJB Foo bean2;
// more code here
20. boolean test1 = beanl.equals(bean1);
21. boolean test2 = beanl.equals(bean2) ;
Which three statements are true? (Choose three)

Given the following client-side code that makes use of the session bean Foo:
10. @EJB Foo bean1;
12. @EJB Foo bean2;
// more code here
20. boolean test1 = beanl.equals(bean1);
21. boolean test2 = beanl.equals(bean2) ;
Which three statements are true? (Choose three)

A.
If Foo is stateful, test1 is true, and test2 is true.

B.
If Foo is stateful, test1 is true, and test2 is false.

C.
If Foo is stateless, test1 is true, and test2 is true.

D.
If Foo is stateless, test1 is true, and test2 is false.

E.
If Foo is singleton, test1 is true, and test2 is true.

F.
If Foo is singleton, test1 is true, and test2 is false.



Leave a Reply 10

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


imran

imran

Why you people are opting for B

Mohamed Fayek

Mohamed Fayek

THE correct answer should be BCE

Mohamed Fayek

Mohamed Fayek

the correct answer should be ABC :

In a nutshell, Stateless session bean references (pointing to the same interface) are always considered equal and so the b1.equals(b2) will always return true if b1 and b2 are referring to the same interface of the same stateless session bean. This applies to singleton session beans as well because singleton beans are stateless session beans. References to stateful session beans are always considered different. So if you acquire the reference to the same statful session bean multiple times, all the reference are un-equal and the equals() method check will return false. An equals() check on the same reference  i.e. b1.equals(b1) returns true for all kinds of beans.

Mohamed Fayek

Mohamed Fayek

SORRY I WAS CONFUSED , the correct answer is BCE :

In a nutshell, Stateless session bean references (pointing to the same interface) are always considered equal and so the b1.equals(b2) will always return true if b1 and b2 are referring to the same interface of the same stateless session bean. This applies to singleton session beans as well because singleton beans are stateless session beans. References to stateful session beans are always considered different. So if you acquire the reference to the same statful session bean multiple times, all the reference are un-equal and the equals() method check will return false. An equals() check on the same reference  i.e. b1.equals(b1) returns true for all kinds of beans.

Piotr Sawicki

Piotr Sawicki

In my opinion there is no single correct answer as beanl is nowhere mentioned before, therefore we don’t know beanl bean1, but assuming l = 1 then BCE 🙂