• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Sample Question from 287

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic