• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

two object references to a session bean's home interface

 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A client has two object references to a session bean's home interface. How can it find out whether the object references are accessing the same object?

Select 1 correct option.

1 Using the == operator.

2 Using the equals() method.

3 Using the isIdentical() method.

4 Using the isEqual() method.

5 Get the PrimaryKey for both and then use equals() method to compare the primary keys.

6 Get the PrimaryKey for both and then use isIdentical() method to compare the primary keys.

7 None of these.
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note, both are references to home object. So you cannot use isIdentical() method. Other options are invalid for session beans. My answer would be None of the above.
 
Ganeshji Marwaha
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keerthi,
I was thinking of the same answer when i had a look at your post. And, i am sure it is perfect..

But i have a related question.. So, if a client really has2 references to the same home object, he should pretty much be able to use *instanceof* operator... I am assuming this because, there is going to be only one home for a deployed bean type. Am i correct or am i missing something.
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instanceof operator can tell you whether a reference is referencing an object of a specified type. It cannot tell you if 2 references are referencing the same object. Moreover, the spec does not guarantee that there will be only one EJBHome object for each bean type.
 
Ganeshji Marwaha
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank u keerthi, was just curious.
 
Deep Chand
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keerthi,

I think the answer should be 1. You can compare 2 references using == . Am I missing something here?

Thanks
Deep
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic