Hi Everyone, This is one of the mock exam questions. Please go through the code..
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 Select Two options:
What might be the correct answer to this question. Thanks in Advance
There is good chance that the primary key classes of the beans are messed up. So I choose options 1 and 2. I'm counting on my container to return correct primary keys and handles. So I trust that the getPrimaryKey() and getHandle() methods work perfectly
I'm sincerely hoping that the real exam does not have these type of questions.
A client can test whether two entity object references refer to the same entity object by using the isIdentical method. Alternatively, if a client obtains two entity object references from the same home, it can determine if they refer to the same entity by comparing their primary keys using the equals method
Further Enterprise JavaBeans architecture does not specify �object equality� (i.e. use of the == operator) for entity object references. The result of comparing two object references using the Java programming language Object.equals(Object obj) method is unspecified. Performing the Object.hashCode() method on two object references that represent the entity object is not guaranteed to yield the same result.
As per me (1) and (3) are the correct answers so you retrieve the primary keys for the entity beans and compare the primary keys using equals method.
Ravi [ March 01, 2005: Message edited by: Ravindra Janapareddy ]
SCJP, SCJD, SCWCD, SCBCD, SCEA
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
Two software engineers solve most of the world's problems in one K&R sized book