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

Mock Exam Question

 
Rahul Mishra
Ranch Hand
Posts: 211
  • 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?


Options

Select 1 correct option.
Using the == operator.

Using the equals() method.

Using the isIdentical() method.

Using the isEqual() method.

Get the PrimaryKey for both and then use equals() method to compare the primary keys.

Get the PrimaryKey for both and then use isIdentical() method to compare the primary keys.

None of these.


Answer according to JDiscuss:None of these

References of the home interface of the same bean are always identical because there is only one instance of the Home interface.


Isnt the question assuming that we are talking about Stateless Session beans.Because for a Stateful bean , no two instances are ever alike..

So,

If you get them alike...its stateless...
if you dont..its stateful..

but this will be found out only after running isIdentical(). That was my answer.Any more insights?
 
k space
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a very tricky question. I got it wrong too, because of over looked the bean's home interface and mis-interpreted to the bean's component interface. I think jdiscuss's explanation is correct.

Back to your assumption:
Because for a Stateful bean , no two instances are ever alike..

It depends on what you are referring to: the bean instances on the sever side, or the bean references on the client side.

You may have two object references (on the client side) pointing to the same stateful session bean, e.g. the 1st was obtained directly from say home.create(100), and the 2nd was from the handle of the 1st reference.

In this case, the isIdentical should return true.
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grrrr....i hate it when i do that
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements regarding an enterprise bean's environment are correct?


1.The container provides the tools that allow the deployer to create and manage the enterprise bean's environment.
2.Enterprise bean instances can modify the values of the environment entries at runtime.
3.The deployer sets and modifies the values of the environment entries by editing the enterprise bean's deployment descriptor.
4.Enterprise bean instances obtain the values of the environment entries from the enterprise bean's deployment descriptor.
5.Enterprise bean instances use the JNDI interfaces to obtain the values of the environment entries.
Answers 1 and 5 are correct.
Answer 2 is incorrect because enterprise bean instances can only read the values of the environment entries at runtime and are not able to modify them. Answers 3 and 4 are incorrect because the deployment descriptor is used to define only the environment entries, as opposed to the values that the enterprise bean expects to be provided at runtime.

Can someone explain a bit in detail why 3 and 4 are wrong?...as far as i remember we specify even the values in Deployment Descriptor
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic