Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

two object references to a session bean's home interface

 
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.
 
Ranch Hand
Posts: 211
  • 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.
 
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: 211
  • 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.
 
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
 
If you look closely at this tiny ad, you will see five bicycles and a naked woman:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic