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.
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
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book