Entity Beans - Quiz Explanation

The answers you selected are indicated below, along with text that explains the correct answers.
 
1. Which of the following properties of stateful session beans are true:
Please select the best answer.
  A. There is a many-to-one relationship between the client and the session bean instance.
  B. Session bean instances live forever.
  C. The container may discard the bean instance arbitrarily, when and if it needs to, for performance reasons.
  D. Stateful session beans may have initial state information passed to them from the client when they are created.
  The correct answer is D .
D is the correct answer because the client can pass information to the session bean instance when it is created.
A is incorrect because clients and session bean instances have a one-to-one relationship, always, by definition. B is incorrect because, once created, session beans live until one of the following happens: the client requests the container to remove the bean instance, or the container crashes and the bean instance is discarded. C is incorrect because, although the container may store the bean instance out on secondary storage for performance reasons, it must read it back in as soon as the client invokes one of its methods.


2. Which of the properties of entity beans are true:
Please select the best answer.
  A. Clients of entity beans have a one-to-one relationship with entity bean instances.
  B. Entity bean instances may not be discarded by the container if it needs to free up resources.
  C. Each entity bean instance has a unique identity.
  D. Entity beans map to one or more pieces of data, each one of which has a unique primary key.
  The correct answer is C.
B is correct because entity bean instances can be discarded by the container. As an entity bean instance is a representation of its underlying data, the instance must synchronize the underlying data with its state before being discarded. C is correct because each entity bean instance represents a unique piece of data that has a unique identity. Thus the bean instance has a unique identity that relates directly to the data it represents. A is incorrect because clients have a many-to-one relationship with their entity bean instances. D is incorrect because an entity bean instance relates to a single unique piece of data that can be identified by a single primary key.