Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sample Question from 287

 
Vishnu Munnangi
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

Today I wrote the pre-assessment exam for the IBM- 287 exam. And I found this question below?
A session bean is executing the methods of two entity beans. While executing isIdentical() of two entity beans is showing that they are same even though they are not, then how can you determine that they are not identical?

1. compare their equals method in the Primary key class
2. compare their hashcode method in the Primary key class
3. find out the getPrimaryKey method from their respective entity bean class
4. find out from the getHandle method from their respective entity bean class

I answered 1 and 3 as correct. Donno whether it is correct? Can any one guess what the correct answer could be?
Thanks in Advance.
 
Lin Feng
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To me only the 1 is correct.

The following is an excerpt from J2EE Tutorial

To determine if two entity beans are identical, the client can invoke the isIdentical method, or it can fetch and compare the beans's primary keys:

String key1 = (String)accta.getPrimaryKey();
String key2 = (String)acctb.getPrimaryKey();

if (key1.compareTo(key2) == 0)
System.out.println("equal");

So 1 is correct.

The JDK document mentions that It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results.

Then 2 is incorrect


The 3 says that to find out the getPrimaryKey method from their respective entity bean class
However the respective entity bean class should be the EJB class implements the EntityBean interface other than the reference implements the EJBObject or EJBLocalObject. It does not have such a method called getPrimaryKey. The Bean class can get it from its entity context object.

I do not think this one is right.

The 4 does not make sense. The EntityBean class can call the getEJBObject() or getEJBLocalObject() to retrieve the reference. However if we have the reference object , we do not need the Handler. And there is no Handler for EJBLocalObject.

As far as we know I have to select 2 from 4 but I only have 1. I would bet they phrased the 3 incorrecly. What they wanted to say was getPrimaryKey method from the entity bean reference. Then I select 1 and 3 for this question.


That is my 2 cents

Thanks

Lin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic