Answer: C: Exam Name: Exam Type: Exam Code: Total Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 0

Exam Name: Sun Certified Bus.

Component Developer java EE Platform 5


Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 1 of 61


Question: 1
Which is a valid Post Construct method in a message-driven bean class?

A - @Post Construct
public boolean init() {return true; }
B - @Post Construct
private static void init() {}
C - @Post Construct
private void init() {}
D - @Post Construct
public static void init() {}

Answer: C

Question: 2
Given:

11. Entity public class X {
12. @ld int id;
13. Y y,
14.}

A public class Y with NO J ava Persistence annotations is defined in the same package.

Which statement is correct about these classes if NO other annotations and mapping descriptors
are provided?

A - Class Y must be serializable.
B - Class Y must be marked as an entity.
C - The entity X is not defined correctly. The field y must be marked as @Lob.
D - Class Y must be accessed by a persistence application through a public interface.

Answer: A

Question: 3
A developer is working on a user registration application using EJ B 3.0. A business method
register User in stateless session bean RegistrationBean performs the user registration. The
register User method executes in a transaction context started by the client. If some invalid user
data causes the registration to fail, the client invokes register user again with corrected data using
the same transaction. Which design can meet this requirement?

A - Have register User method call EJ BContext.setRollbackOnly() method after registration fails.
B - Have register User method throw javax.ejb.EJ BTransactionRequiredException after
registration fails.
C - Have register User method throw EJ BException without marking the transaction for rollback,
after registration fails.
D - Create an application exception with the rollback attribute set to false and have register User
method throw it after registration fails.

Answer: D

Question: 4
Which two class types must be implicitly or explicitly denoted in the persistence.xml descriptor as
managed persistence classes to be included within a persistence unit? (Choose two.)

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 2 of 61


A - Entity classes
B - Interceptor classes
C - Embedded classes
D - Entity listener classes

Answer: A, C

Question: 5
Which statement about the combination of mapping defaults, annotations, and XML descriptors is
correct?

A - All mapping annotations must always be processed by the persistence provider.
B - Some annotations, like the @Entity annotation, must always be processed by the persistence
provider.
C - The mapping information for an entity class specified by annotations and in XML descriptors
must be distinct.
D - If multiple entity listeners are defined, the order in which they are invoked can be defined or
overwritten in the XML descriptor.

Answer: D

Question: 6
Which statement about an entity instance lifecycle is correct?

A - A new entity instance is an instance with a fully populated state.
B - A detached entity instance is an instance with no persistent identity.
C - A removed entity instance is NOT associated with a persistence context.
D - A managed entity instance is the instance associated with a persistence context.

Answer: D

Question: 7
A developer implements a session bean with a method doStuff which behaves differently
depending on the callers security role. Only users in security roles ADMIN and USER are
allowed to call the method. Assume that there is no security-related metadata in the deployment
descriptor. Which two, taken in combination, are appropriate to accomplish this? (Choose two.)

A - Annotate method doStuff with @PermitAll.
B - Annotate method doStuff with @RolesAllowed({ADMIN,USER})
C - lf EjBContext.getCallerPrincipal returns role ADMIN, implement the behavior for users in role
ADMIN.
D - If EJ BContext.isCallerlnRole(ADMIN) returns true, implement the behavior defined for users
in role ADMIN.

Answer: B, D

Question: 8
A developer wants to create a portable EJ B 3.0 application that includes the following class
definition for the Entity Account

11. @Entity
12. @EntityListeners(com.acme.AlertMonitor.class)
13. public class Account {
14. // more code here
15. @PrePersist
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 3 of 61


16. protected void validatecreate() {/* more code here */}
17.}

Which statement is correct?

A - The validateCreate method may NOT throw runtime exceptions.
B - The validateCreate method can invoke the EntityManager.flush operation.
C - Methods of the class com.acme.AlertMonitor annotated with callback annotations must take
an Object or Account instance as the only argument.
D - The above class definition is NOT correct. An entity cannot define a callback method like
PrePersist and use the EntityListeners annotation at the same time.

Answer: C

Question: 9
Given:

11. @PersistenceContext EntityManager em;
12. public boolean test(Order o){
13. boolean b =false;
14. o =em.merge(o);
15 em.remove(o);
16. o =em.merge(o);
17. b =em.contains(o);
18. return b;
19. }

Which statement is correct?

A - The method will return TRUE.
B - The method will return FALSE.
C - The method will throw an exception.
D - The Order instance will be removed from the database.

Answer: C

Question: 10
The deployment descriptor for a stateless session bean that uses the isCallerlnRole method
reads as follows:

3. <security-role-ret>
4. <role-name>manager</role-name>
5. <role-link>humanresources</role-link>
6. <security-role-ret>

16. <security-role>
17. <description>
18. Is allowed to view and update all employee records.
19. </description>
20. <role-name>humanresources</role-name>
21. </security-role>

Which two roles are responsible for creating this deployment descriptor? (Choose two.)

A - Deployer
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 4 of 61


B - Bean Provider
C - System Administrator
D - Application Assembler

Answer: B, D

Question: 11
Given two entities with a many-to-many bidirectional association between them:

11 @Entity public class Employee {
12. Collection projects;
13. // more code here
14. }

and

11. @Entity public class Project{
12. Set<Employee>emps;
13. // more code here
14. }

What set of annotations correctly defines the association?

A - @ManyToMany on the projects field,
@ManyToMany(mappedBy=projects) on the emps field
B - @ManyToMany(mappedBy=emps) on the projects field,
@ManyToMany on the emps field
C - @ManyToMany(targetEntity=Project.class) on the projects field,
@ManyToMany(mappedBy=projects) on the emps field
D - @ManyToMany(targetEntity=Project.class) on the projects field,
ManyToMany on the emps field

Answer: C

Question: 12
Given code snippets from two files:

7. public class Dog {
8. public void onMessage(Message m) {System.out.print(1); }
9. }

and

10. @MessageDriven
11. class MessageDog extends Dog implements MessageDrivenBean {
12. MessageDog(Message m) {System .out.print(2); }
13: }

Which four code changes, when used together, create a valid J MS message-driven bean?
(Choose four.)

A - Make class MessageDog public.
B - Make the MessageDog constructor no-arg.
C - Make the MessageDog constructor public.
D - Move the onMessage method to class MessageDog.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 5 of 61


E - Change MessageDog so that it is NOT a subclass of Dog.
F - Make class MessageDog implement MessageListener instead of MessageDrivenBean.

Answer: A, B, C, F

Question: 13
Which statement about entity manager is true?

A - A container-managed entity manager must be a J TA entity manager.
B - An entity manager injected into session beans can use either J TA or resource-local
transaction control.
C - An entity manager created by calling the EntityManagerFactory.createEntityManager method
always uses J TA transaction control.
D - An entity manager obtained through resource injection in a stateful session bean can use a
resource-local EntityTransaction for transaction control.

Answer: A

Question: 14
Which two options can be used to predefine J ava Persistence queries for easy use? (Choose
two.)

A - @NamedQuery annotation
B - @NamedNativeQuery annotation
C - using the named-query element in the XML descriptor
D - using the named-native-query element in the XML descriptor

Answer: A, C

Question: 15
Given a set of CMT bean methods with the following transaction attributes:

Method M1 =SUPPORTS
Method M2=REQUIRED
Method M3=NOT SUPPORTED
Method M4=REQUIRES_NEW

And the following method invocation sequence:

Method M1 invokes Method M2
Method M2 invokes Method M3
Method M1 invokes Method M4

If Method M1 is invoked by a method that does NOT have a transaction context, which describes
a possible scenario?

A - Method M1: no transaction
Method M2: new transaction
Method M3: no transaction
Method M4: new transaction
B - Method M1: no transaction Method M2:
Container throws EJ BTransactionRequiredException
C - Method M1: new transaction
Method M2: runs in same transaction as M1
Method M3: Container throws TransactionNotSupportedException
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 6 of 61


D - Method M1: no transaction Method M2: new transaction
Method M3: Container throws TransactionNotSupportedException

Answer: A

Question: 16
A developer wants to create a J ava Persistence query that returns valid U.S. phone numbers
(formatted as 123-456-7890 or 800-RUN-EJ B3) from a collection of differently formatted
international phone numbers. The developer needs only those numbers that begin with 303.
Which WHERE clause is correct?

A - WHERE addr.phone LIKE 303_
B - WHERE addr.phone LIKE 303%
C - WHERE addr.phone LIKE 303-_-_
D - WHERE addr.phone LIKE 303-%-%
E - WHERE addr.phone LIKE 303--
F - WHERE addr.phone LIKE 303-%%%-%%%%

Answer: E

Question: 17
A developer is working on a project that includes both EJ B 2.1 and EJ B 3.0 session beans. A lot
of business logic has been implemented and tested in these EJ B 2.1 session beans. Some EJ B
3.0 session beans need to access this business logic.

Which design approach can achieve this requirement?

A - Add adapted home interfaces to EJ B 3.0 session beans to make EJ B 3.0 and EJ B 2.1 session
beans interoperable.
B - Add EJ B 3.0 business interfaces to existing EJ B 2.1 session beans and inject references to
these business interfaces into EJ B 3.0 session beans.
C - No need to modify existing EJ B 2.1 session beans. Use the @EJ B annotation to inject a
reference to the EJ B 2.1 home interface into the EJ E 3.0 bean class.
D - No need to modify existing EJ A 2.1 session beans. Use the @EJ B annotation to inject a
reference to the EJ A 2.1 component interface into the EJ B 3.0 bean class.

Answer: C

Question: 18
A developer is modifying an existing J ava EE application that uses the J DBC API to access a
database. This code must be used but cannot be changed, and new code needs to be added that
uses the J ava Persistence API.

Both parts of the code will execute in the same J TA transaction.

Which method of the EntityManager interface should the new code use to ensure that the data
read by J DBC statements includes the state of managed entities?

A - Call refresh on each changed entity.
B - Call flush at the end of each business method.
C - Call find before accessing any managed entity.
D - Call lock at the beginning of each business method.

Answer: B

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 7 of 61


Question: 19
A developer wants to achieve the following two behaviors for an EJ B 3.0 session bean:

(1) If the client calls a business method with a transaction context, the container will invoke the
enterprise beans method in the clients transaction context.
(2) If the client calls a business method without a transaction context, the container will throw the
javax.ejb.EJ BTransactionRequiredException.

Which transaction attribute should be used?

A - REQUIRED
B - SUPPORTS
C - MANDATORY
D - REQUIRES_NEW
E - NOT_SUPPORTED

Answer: C

Question: 20
Given a stateless session bean with container-managed transaction demarcation, from which two
methods can a developer access another enterprise bean? (Choose two.)

A - bean constructor
B - Timeout callback method
C - PreDestroy lifecycle callback method
D - PostConstruct lifecycle callback method
E - business method from the business interface

Answer: B, E

Question: 21
Which two are programming restrictions in the EJ B 3.0 specification? (Choose two.)

A - An enterprise bean must NOT attempt to load a native library.
B - An enterprise bean must NOT declare static fields as final.
C - An enterprise bean must NOT attempt to create a new security manager.
D - An enterprise bean must NOT propagate a RuntimeException to the container.
E - An enterprise bean must NOT attempt to obtain a javax.naming.lnitialContext.

Answer: A, C

Question: 22
The J ava Persistence API defines a notion of propagation of a persistence context. Which
statement is correct?

A - Persistence context propagation is NOT supported for message-driven beans.
B - Persistence context propagation is supported for any type of an entity manager.
C - Persistence context propagation avoids the need for the application to pass references of
entity manager instances.
D - Persistence context propagation results in cloning of all managed instances for use by
another instance of an entity manager.

Answer: C

Question: 23
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 8 of 61


Given the following statements about an EJ B deployment descriptor for which the metadata-
complete attribute is not specified:

I. The EJ B deployment descriptor can provide additional metadata to bean class annotations.
II. The EJ B deployment descriptor can partially override bean class annotations.
Ill. The EJ B deployment descriptor can entirely override bean class annotations.

Which is true?

A - Only statement I is correct.
B - Only statement II is correct.
C - Only statement Ill is correct.
D - Both statements I and II are correct.
E - Both statements I and Ill are correct.

Answer: D

Question: 24
Which J ava Persistence query uses the aggregate function correctly, assuming that chairs field is
of type int?

A - SELECT ANY(r.chairs) FROM Room r
B - SELECT NEW Integer(MAX(r.chairs)) FROM Room r
C - SELECT r FROM Room r WHERE r.chairs >AVG(r.chairs)
D - SELECT c FROM Chair c WHERE LOCATE (c.type, lazyboy) >-1

Answer: B

Question: 25
A business method of a stateless session bean with a transaction attribute REQUIRED executes
a J ava Persistence query on a container-managed persistence context.

Under which two conditions can the developer expect the persistence provider to ensure that all
changes made to the persistence context in the transaction are visible to the processing of the
query? (Choose two.)

A - The flush mode is NOT explicitly set.
B - The flush mode on the Query object is set to COMMIT.
C - The refresh method on the EntityManager is called.
D - The flush mode on the persistence context is set to AUTO but is NOT specified for the Query
object.

Answer: A, D

Question: 26
A session bean calls the setRollbackOnly method on the EJ BContext interface within a business
method with an active transaction. Which two are correct? (Choose two.)

A - The transaction timeout is immediately disabled.
B - The container will ensure that the transaction will never commit.
C - The bean must have started the current transaction for this to be legal.
D - The bean must have bean-managed transaction demarcation for this to be legal.
E - The bean must have container-managed transaction demarcation for this to be legal.

Answer: B, E
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 9 of 61



Question: 27
Given:

5. public interface MrB1 {
6. public interface MrB2 {

A java class is defined as:

11 . @Stateless
12. public class MrBean implements MrB1 ,MrB2

Which two statements are correct for making this code work as a stateless session bean,
considering that this session bean is NOT defined in a deployment descriptor and the interfaces
do NOT have annotations? (Choose two.)

A - Only the interface for remote usage must be annotated.
B - The interfaces MrB1 and MrB2 can only be used locally without changing the code.
C - Both interfaces MrB1 and MrB2 must be annotated to make this a working stateless session
bean.
D - The interfaces MrB1 and MrB2 can be annotated differently, one with @Local and the other
with @Remote.

Answer: C, D

Question: 28
A developer wants to write a stateful session bean using the following interface as local business
interface:

1. package acme;
2. public interface Bar {
3. public void bar();
4. }

Assuming there is NOT an ejb-jar.xml file, which code can be inserted into Lines 4-6 below to
define the bean with the ejb name of BarBean?

1. package acme;
2. import javax.ejb.*;
3. import java.io.*;
4.
5.
6.
7. }

A - @Stateful
public class BarEJ B implements Bar {
public void bar() {}
B - @Stateful(name=Bar)
public class BarBean implements Bar {
public void bar() {}
C - @Stateful
public class BarBean implements Serializable, Bar {
public void bar() {}
D - @Stateful(name=Bar)
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 10 of 61


public class BarBean implements Bar {
public void bar() throws java.rmi.RemoteException {}

Answer: C

Question: 29
Given the following client-side code that makes use of the session bean Foo:

10. @EJ B Foo bean1;
11. @EJ B Foo bean2;
//more code here
20. boolean test1 =bean1.equals(bean1);
21. boolean test2 =bean1.equals(bean2);

Which two statements are true? (Choose two.)

A - If Foo is stateful, test1 is true, and test2 is true.
B - If Foo is stateful, test1 is true, and test2 is false.
C - If Foo is stateless, test1 is true, and test2 is true.
D - If Foo is stateful, test1 is false, and test2 is false.
E - If Foo is stateless, test1 is true, and test2 is false.
F - If Foo is stateless, test1 is false, and test2 is false.

Answer: B, C

Question: 30
A developer writes an interceptor class called Foo lnterceptor containing the following
Aroundlnvoke method:

11 . @Aroundlnvoke
12. public Object intercept(lnvocationContext ctx) {
13. return intercepted;
14.}

Foolnterceptor is applied to a business method in a stateless session bean:

11. @lnterceptors(Foolnterceptor.class)
12. public String testzero(int i) {
13. return (i ==0)? zero: not zero;
14. }

Which describes the result when a client invokes the testzero method with a value of 1?

A - The intercept method is NEVER invoked.
B - The client receives a return value of zero.
C - The client receives a return value of not zero.
D - The client receives a return value of intercepted.

Answer: D

Question: 31
Which three statements are true about EJ B 3.0 containers? (Choose three.)

A - Remote argument passing semantics conform to J ava RMI-IIOP.
B - The J AXB 2.0 API is guaranteed to be available for all bean types.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 11 of 61


C - The J ava 2D API is guaranteed to be available for session beans.
D - javax.naming.lnitialContext is guaranteed to provide a J NDI name space.
E - The J ava Telephony API is guaranteed to be available for session and message beans.
F - javax.transaction.UserTransaction cannot be used by beans when bean-managed transaction
demarcation is used.

Answer: A, B, D

Question: 32
Which statement is true about the Timer service in an EJ B 3.0 stateless session bean?

A - The timeout callback method contains the business logic that handles the timeout event.
B - The timeout callback method must be declared as a business method in business interfaces.
C - The timeout callback method can throw application exceptions to report business logic
failures.
D - A bean class can implement multiple timeout callback methods, each associated with a
different timer.

Answer: A

Question: 33
A developer writes a stateful session bean called FooBean.

Which code can be inserted before Line 11 of the FooBean class to define a TYPE-level
environment dependency on a J MS Topic?

11. public class FooBean {
12.
13. publicvoidfoo() {}
14.
15. }

A - @Resource(type=Topic.class)
B - @Resource(name=topicRef)
private static Topic topic;
C - @Resource private Topic topic;
D - @Resource(name=topicRef ,type=Topic.class)

Answer: D

Question: 34
Which two statements are true? (Choose two.)

A - All types of enterprise beans can be transaction-aware.
B - Typically, fine-grained objects, such as an employee record, should be remotely accessible.
C - The client view of any given enterprise bean will be consistent across all EJ A 3.0
containers without the need to recompile the bean.
D - As long as a given enterprise bean is NOT recompiled, its security attributes are guaranteed
to be consistent across all EJ B 3.0 containers in which it is deployed.

Answer: A, C

Question: 35
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 12 of 61


Bean A is using bean-managed transaction demarcation and has invoked the too method of bean
B. When the too method returns, bean A needs to determine if the transaction has been set to
rollback. Which must be true?

A - It is NOT possible for bean A to determine if the transaction has been set to rollback.
B - Bean A must invoke the get Status method on the User Transaction that it began.
C - For this to be possible, bean B must also use bean-managed transaction demarcation.
D - Bean A must invoke the setRollbackOnly method on the User Transaction that it began.
E - Bean A must invoke the getRollbackOnly method on the User Transaction that it began.

Answer: B

Question: 36
Which statement describes a component definition that is allowed by the EJ B 3.0 specification?

A - A stateful session bean that is a Web service endpoint.
B - A stateful session bean that has one remote business interface and is a Web service
endpoint.
C - A message-driven bean that has one message listener interface and is a Web service
endpoint.
D - A stateless session bean that has three local business interfaces and is a Web service
endpoint.

Answer: D

Question: 37
FooBean and BarBean are both EJ B 3.0 stateless session beans with container-managed
transaction demarcation. All business methods in the two beans have transaction attribute
REQUIRED. The business method foo in FooBean invokes the business method bar in BarBean.

Given:

10. public class BarBean {
11. public void bar() {
12. throw new EJ BException(unexpected error.. .)
13. }

Which statement is true about the result of this method invocation assuming execution reaches
Line 12?

A - The container might roll back the transaction.
B - The BarBean bean instance is in the ready state for the next invocation.
C - FooBean.foo method receives javax.ejb.EJ BTransactionRolledbackException.
D - FooBean.foo method receives javax.transaction.lnvalidTransactionException.

Answer: C

Question: 38
Which two statements are correct? (Choose two.)

A - An EJ B 3.0 message-driven bean can itself be the client of another message-driven bean.
B - The client of an EJ B 3.0 message-driven bean can use the beans remote business interface
to communicate with the bean.
C - Every client of an EJ B 3.0 J MS message-driven bean must be a J ava application that uses
the J MS API to communicate with the bean.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 13 of 61


D - Messages sent to J MS topics are intended for only one receiver whereas messages sent to
J MS queues are intended for multiple receivers.
E - If the client of an EJ B 3.0 message-driven bean awaits a reply to its request, the client can set
the J MBReplyTo attribute to provide routing information to the bean.

Answer: A, E

Question: 39
The J ava Persistent API defines certain rules for persistent entities. These rules are required by
the persistent provider to manage entities at runtime. Which statement is correct, assuming NO
mapping descriptor is used?

A - Entities must extend a persistent base class.
B - Entities must implement the interface PersistentEntity to be managed by the persistent
provider.
C - A field without a transient modifier must be annotated as @Persistent to be stored in the
database.
D - A field without a transient modifier must be annotated as @Transient to NOT be stored in the
database.

Answer: D

Question: 40
A developer wants to implement an association relationship between Car Model and Car
Manufacturer. Every car model is produced by a single manufacturer and every manufacturer
produces many car models. While in this application it is essential to quickly determine the
manufacturer of a model it is NOT necessary to determine which models a manufacturer
produces. Given these requirements, which is an appropriate solution?

A - In Car Model class, declare an attribute of type Car Manufacturer and annotate it with
OneToMany.
B - In Car Model class, declare an attribute of type Car Manufacturer and annotate it with
ManyToOne.
C - In Car Manufacturer class, declare an attribute of type Car Model and annotate it with
OneToMany.
D - In Car Manufacturer class, declare an attribute of type Collection<Car Model>and annotate it
with @OneToMany.
E - In Car Model class, declare an attribute of type Collection<Car Manufacturer>and annotate
itwith@nyToone.

Answer: B

Question: 41
Which statement is true about both stateful session beans and stateless session beans?

A - Bean instances are NOT required to survive container crashes.
B - Any bean instance must be able to handle concurrent invocations from different threads.
C - A bean with bean-managed transactions must commit or roll back any transaction before
returning from a business method.
D - The container passivates and activates them using methods annotated with @PrePassivate
and @PostActivate annotations.

Answer: A

Question: 42
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 14 of 61


Which method always throws an exception when invoked on a container-managed entity
manager?

A - the lock method
B - the close method
C - the flush method
D - the clear method

Answer: B

Question: 43
An enterprise bean has security permissions set up using declarative security features. Under
which two conditions can a client be guaranteed to have permission to invoke a business method
on the enterprise bean? (Choose two.)

A - The Application Assembler has marked the enterprise bean method as unchecked.
B - The clients principal has been assigned a security role with permission to invoke the method.
C - The Application Assembler has set the security-identity deployment descriptor to run-as.
D - The Application Assembler has mapped all security role references using the role-link
element.

Answer: A, B

Question: 44
A developer wants to perform programmatic access control inside EJ B 3.0 session beans. This is
needed because some permissions can be determined only at application runtime. Which method
achieves this goal?

A - javax.ejb.EJ BContext.getRollbackOnly()
B - java.lang.SecuritytManager.checkAccess(Thread t)
C - javax.interceptor.lnvocationContext.getTarget()
D - javax.ejb.SessionContext.isCallerlnRole(String roleName)
E - javax.servlet.http.httpServletRequest.getuserPrincipal()

Answer: D

Question: 45
A J ava Persistence application wants to use optimistic locking. Which statement that describes
the functionality of optimistic locking is correct?

A - The Version attribute of an entity using optimistic locking can be mapped to a secondary
table.
B - Optimistic locking can be used by J ava Persistence applications to set optimistic locks on
tables in the database.
C - The Version attribute of an entity using optimistic locking is verified each time the instance is
loaded from the database.
D - Optimistic locking ensures that updates or deletes are consistent with the current state of the
database and that intervening updates are not lost.

Answer: D

Question: 46
Consider a deep inheritance hierarchy consisting of J ava Persistence entity classes, non-entities,
and mapped super classes. Which statement is correct, assuming NO mapping descriptor is
present?
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 15 of 61



A - An entity class must NOT inherit from a non-entity class.
B - An entity class must NOT be extended by a non-entity class.
C - Only the root class in an inheritance hierarchy can be annotated wtith @MappedSuperclass.
D - The primary key must either be defined in the topmost entity class of the inheritance hierarchy
or it can be defined in a superclass if this class is annotated as @MappedSuperclass.

Answer: D

Question: 47
Which statement is true about the primary key of a J ava Persistence entity?

A - The primary key cannot be overridden by a mapping descriptor.
B - The location of the primary key defines the topmost entity class in the hierarchy.
C - If property-based access is used, the properties or the primary key class must be public or
protected.
D - At least part of a primary key must be defined in the class that is the topmost class of an entity
which is defined by a hierarchy of classes.

Answer: C

Question: 48
The ejb-jar file format is a contract between which two EJ B role pairs? (Choose two.)

A - Deployer and System Administrator
B - Application Assembler and Deployer
C - Sean Provider and Application Assembler
D - Bean Provider and EJ B Container Provider
E - EJ B Server Provider and EJ B Container Provider
F - Application Assembler and EJ B Container Provider

Answer: B, C

Question: 49
Which two can be specified by both the Bean Provider and the Application Assembler? (Choose
two.)

A - security roles
B - enterprise bean type
C - transaction attributes
D - session beans state-management type
E - enterprise beans remote home interface
F - enterprise beans local business interface

Answer: A, C

Question: 50
A session beans business method throws an exception during execution. Which two are
responsibilities of the Bean Provider when throwing the exception? (Choose two.)

A - For application exceptions, ensure that if the current transaction commits there will be no loss
of data integrity.
B - For application exceptions, ensure that the current transaction will commit.
C - For system errors, when the client is remote, throw a java.rmi.RemoteException that wraps
the original exception.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 16 of 61


D - For checked exceptions from which the bean cannot recover, throw an EJ BException that
wraps the original exception.

Answer: A, D

Question: 51
Which is a correct way of defining a runtime exception as an EJ B 3.0 application exception?

A - public class MyAppException extends javax.ejb.EJ BException
B - @ApplicationException
public class MyAppException extends java.rmi.RemoteException
C - public class MyAppException extends java.Iang.RuntimeException
D - @ApplicationException
public class MyAppException extends java.Iang.RuntimeException

Answer: D

Question: 52
Which is a valid way of injecting a container-managed transaction-scoped persistence context
into an EJ B 3.0 session bean assuming the application contains only one persistence unit?

A - @PersistenceUnit
public EntityManager em;
B - @PersistenceContext
private EntityManager em;
C - @TransactionManagement(TransactionManagementType.CONTAlNER)
public EntityManager em;
D - @Resource(name=persistence/em, authenticationType=AuthenticationType.CONTAINER)
protected EntityManager em;

Answer: B

Question: 53
Place the EJ B 3.0 J MS Message-Driven Bean class code snippets on their corresponding
locations.

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 17 of 61




Answer:



Question: 54
A Department entity is in a one-to-many relationship with an Employee entity. A developer has
been asked to write a J ava Persistence query to update the set of employees who are in the
department HR by setting their department to null.

Construct a query using the J ava Persistence query language to perform this task.

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 18 of 61




Answer:



Question: 55
A developer implemented a J ava class called Store. The class is annotated correctly to act as an
entity. The developer created a stateless session bean to create, lookup, and remove Store
objects. This session bean has a container-managed entity manager injected into field em and a
removeStore method with transaction attribute REQUIRED.

Given the following code:

32. public void removeStore(Store store) {
33. em.remove(store);
34. }

What is a possible reason that an IllegalArgumentException is thrown at Line 33 when the
removeStore method is called by a remote client?

A - The passed object is NOT serializable.
B - The passed object is NOT found in the database.
C - The passed object is NOT managed by the entity manager.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 19 of 61


D - There is no active transaction to manage the database removal.

Answer: C

Question: 56
A developer is implementing a message-listener method of an EJ B 3.0 message-driven bean.
The developer wants to make sure that the message receipt is immediately rolled back in case
the message listener method is aborted with a runtime exception. Which option can the developer
use?

A - Use Container-Managed Transactions with transaction attribute REQUIRED.
B - Use Container-Managed Transactions with transaction attribute NOT_SUPPORTED.
C - Use Bean-Managed Transactions and the J MS API for message acknowledgement.
D - Use Bean-Managed Transactions and write a try-catch-finally block that calls
UserTransaction.rollback in case of a RuntimeException.

Answer: A

Question: 57
A developer creates a stateful session bean that is used by many concurrent clients. The clients
are written by other development teams and it is assumed that these clients might not remove the
bean when ending their session. The number of concurrent sessions will be greater than the
defined bean cache size. The developer must consider that the state of the session bean can be
influenced by either passivation or timeout. Which three actions should the developer take to
make the bean behave correctly in passivation and timeout situations? (Choose three.)

A - Release references to resources in a @Remove annotated method.
B - Re-establish references to resources in an @lnit annotated method.
C - Release references to resources in a @PreDestroy annotated method.
D - Release references to resources in a @PrePassivate annotated method.
E - Re-establish references to resources in a @PostActivate annotated method.

Answer: C, D, E

Question: 58
A Reader entity has a one-to-many, bidirectional relationship with a Book entity. Two Reader
entities are persisted, each having two Book entities associated with them. For example, reader 1
has book a and book b, while reader 2 has bookc and bookd. Which query returns a Collection of
fewer than four elements?

A - SELECT b.reader FROM Book b
B - SELECT r FROM Book b INNER J OIN b.reader r
C - SELECT r FROM Reader r INNER J OIN r.books b
D - SELECT r from Book b LEFT J OIN b.reader r LEFT J OIN FETCH r.books

Answer: C

Question: 59
Given:

10. @Stateless
11 @RunAs(X)
12. public class SecureBean01 implements Secure01 {
13. @EJ B Secure02 secure02;

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 20 of 61


23. @RolesAllowed(A)
24. public void methodA() {
25. secure02.methodB();
26. }

10. @Stateless
11. public void SecureBean02 implements Secure02 {

23. @RolesAllowed(A)
24. public void methodB()

A user who is only in role A invokes Secure01.methodA. Assuming NO other security-related
metadata, what is the expected result?

A - An exception is thrown at Line 25.
B - An exception is thrown at Line 13.
C - method A cannot be invoked by this user.
D - The code executes without raising an exception.

Answer: A

Question: 60
Given the following stateful session bean:

10. @Stateful
11. @TransactionAttribute(TransactionAttributeType.SUPPORTS)
12. public class VideoBean implements Video {
13. //insert code here
14. public void methodA() {}
15.}

Assuming no other transaction-related metadata, which code can be added at Line 13 to
guarantee that business method methodA will execute only if invoked with an active transaction?

A - @TransactionAttribute()
B - @TransactionManagement(TransactionAttributeType.CONTAlNER)
C - @TransactionAttribute(TransactionAttributeType.MANDATORY)
D - @TransactionAttribute(TransactionAttributeType.REQUlRES_NEW)

Answer: C

Question: 61
Given:

1. public class MyException extends Exception {}

The remote business interface Foo declares a method work():

5. public void work() throws MyException;

The bean class FooBean contains the following:

10. @Stateless
11. @Remote(Foo.class)
12. public class FooBean{
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 21 of 61


13. public void work() throws MyException {
14. throw new MyException();
15. }

Which exception can be received in the client as a result of invoking the work method?

A - a MyException
B - a javax.ejb.ConcurrentAccessException
C - a javax.ejb.EJ BException that wraps an instance of MyException as the root cause
D - a java.rmi.RemoteException that wraps an instance of MyException as the root cause

Answer: A

Question: 62
A developer wants to release resources within a stateless session bean class. The cleanup
method should be executed by the container before an instance of the class is removed. The
deployment descriptor is NOT used. Which three statements are correct? (Choose three.)

A - The cleanup method may declare checked exceptions.
B - The cleanup method must have no arguments and return void.
C - The cleanup method is executed in an unspecified transaction and security context.
D - The developer should mark the cleanup method with the PreDestroy annotation.
E - The developer should mark the cleanup method with the PostDestroy annotation.
F - The cleanup method is executed in the transaction and security context of the last business
method invocation.

Answer: B, C, D

Question: 63
A developer wants to create a J MS message-driven bean that responds to
javax.jms.TextMessage messages. Which two statements are true? (Choose two.)

A - The developer must implement the ejbCreate method.
B - The developer does NOT need to create a business interface for the bean.
C - The developer must implement a method that declares javax.jms.TextMessage as an
argument.
D - The message-driven bean class must implement methods of the javax.jms.MessageListener
interface
E - The message-driven bean class must implement methods of the
javax.ejb.MessageDrivenBean interface.

Answer: B, D

Question: 64
A J ava Persistence application uses the EntityManager.flush method to synchronize the current
persistence context with the database. Which two statements are correct? (Choose two.)

A - The flush method might cause the persist operation to be cascaded to related entities.
B - Extensive use of the flush method decreases the performance of a J ava Persistence
application.
C - The flush method should be used to synchronize the current persistence context with
modifications made in other transactions.
D - The flush method should be used to publish changes done in the current persistence context
to other transactions before actual transaction commit.

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 22 of 61


Answer: A, B

Question: 65
Your application uses the J ava Persistence API to access a database. This application must
reject adding an instance to the database if it does NOT pass validation tests for values of two
persistence properties. The database contains some data that will NOT pass such validation.
Only the new records must be validated. Which option will achieve this behavior?

A - Add validation logic to the setter methods for each property.
B - Add the PrePersist callback method with all of the validation logic.
C - Add the PostPersist callback method with all of the validation logic.
D - Add PrePersist and PreUpdate callback methods with all of the validation logic.

Answer: B

Question: 66
Given an EJ B 3.0 J MS message-driven bean, which statement is true about its exception
handling?

A - Its message listener method must NOT throw any checked exception.
B - Its message listener method can throw java.rmi.RemoteException.
C - Its message listener method can throw any checked exception
exceptjava.rmi.RemoteException.
D - Its message listener method can throw any checked exception that implements java.io
Serializable.

Answer: A

Question: 67
FooBean is an EJ B 3.0 session bean that can make valid use of UserTransaction. Which is
guaranteed to work in an EJ B container for FooBean to obtain the UserTransaction object?

A - Invoke a method on a SessionContext Transaction object.
B - Perform J NDI lookup with name java:/UserTransaction on an InitialContext.
C - Perform J NDI lookup with the name jdbc/UserTransaction on an lnitialContext.
D - Use the TransactionManagement annotation to inject an instance variable of type
UserTransaction in a bean class.

Answer: A

Question: 68
A developer creates a stateless session bean, EmployeeServiceBean, and its interface,
EmployeeService. The session bean uses two annotated entity classes, Employee.class and
Department.class, Which two packaging options can the developer use when creating a
deployable EAR? The proposed directory structure is listed for each option. (Choose two.)

A - emp.ear
emp-ejb.jar
META-INF/persistence.xml
EmployeeService.class
EmployeeServiceBean.class
lib/emp-classes.jar
Employee.class
Department.class
B - emp.ear
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 23 of 61


META-INF/orm.xml
emp-ejb.jar
EmployeeService.class
EmployeeServiceBean.class
Employee.class
Department.class
C - emp.ear
emp-ejb.jar
META-INF/persistence.xml
Employee.class
Department.class
EmployeeService.class
EmployeeServiceBean.class
D - emp.ear
emp-ejb.jar
persistence.xml
Employee.class
Department.class
EmployeeService.class
EmployeeServiceBean.class

Answer: A, C

Question: 69
A developer writes an enterprise application and packages it into an enterprise archive (EAR).
The application contains one persistence unit with unit name FooPU. The application also
contains an ejb-jar with one stateless session bean. Which code, when added to the stateless
session bean class, injects a container-managed persistence context at runtime?

A - @PersistenceContext
EntityManager em;
B - @Resource(unitName=FooPU)
EntityManager em;
C - @PersistenceUnit(unitName=FooPU)
EntityManager em;
D - @PersistenceContext(unitName=persistence/FooPU)
EntityManager em;

Answer: A

Question: 70
The J ava Persistence API defines the Query interface. Which two statements about the
Query.executeUpdate method are true? (Choose two.)

A - It must always be executed within a transaction.
B - It throws a PersistenceException if no entities were updated.
C - It throws an lIlegalStateException if called on a Query instance created with a J ava
Persistence SELECT query.
D - All managed entity objects corresponding to database rows affected by the update will have
their state changed to correspond with the update.

Answer: A, C

Question: 71
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 24 of 61


A developer obtains a java.security.Principal object by calling the
SessionContext.getCallerPrincipal method from within a business method of a session bean.
Which statement is true?

A - The returned Principal object can be null.
B - The roles which the Principal is in can be determined from this Principal object.
C - The return value of Principal.getName depends on the security realm which was used to
authenticate the caller.
D - The return value of the Principal.getName method is exactly the same as the username used
for authentication of the caller.

Answer: C

Question: 72
The bean class of an EJ B Web service endpoint has one method annotated with @WebMethod.

Which two types can be legally returned from that method? (Choose two.)

A - java util Date
B - javax.ejb.Timer
C - an array of java.lang.String
D - an EJ B 3.0 local business interface reference
E - an EJ B 3.0 remote business interface reference

Answer: A, C

Question: 73
A J ava EE 5 Application server has four different security realms for user management. One of
the security realms is custom made. This realm supports only individual user entries, no grouping
of users, and is used by the application. Which two statements are true? (Choose two.)

A - EJ A developers cannot use the isCallerlnRole method.
B - The annotation @RunAs(AAA) can still be used for this application.
C - All security roles need a role-link entry in the deployment descriptor.
D - All security roles can be mapped successfully to individual users in the realm.

Answer: B, D

Question: 74
A developer wants to create a business interface for both local and remote usage. For
performance reasons the remote interface should NOT be called by a client in the same J VM.
Which statement is required to accomplish this, assuming there is no deployment descriptor?

A - The business methods are defined in one interface which must be annotated with both
@Local and @Remote.
B - The business methods are defined twice in one interface. One method is annotated with
@Local and the other is annotated with @Remote.
C - The business methods are defined in a common interface by two other interfaces which are
annotated with @Local and @Remote respectively. The bean implements the super interface.
D - The business methods are defined in a common interface. It is extended by two interfaces,
annotated with @Local and @Remote respectively. Both interfaces are implemented by the
bean class.

Answer: D

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 25 of 61


Question: 75
Given this J ava EE application that uses a J TA application-managed entity manager:

20. UserTransaction utx =;
21. utx.begin();
22. //insert code here
23. utx.commit();

Which two code fragments can be used on Line 22 to persist an order instance assuming that all
references are property initialized? (Choose two.)

A - em.merge(order);
em.flush();
B - em.persist(order);
em.flush();
C - em.joinTransaction();
em.persist(order);
D - em =emf.createEntityManager();
em.persist(order);

Answer: C, D

Question: 76
Consider the following classes:

11. @Entity Auction
12. @Id int id;
13. @OneToOne Item item;
14. }

11. @Entity Item {
12. @Id int id;
13. @OneToOne (mappedBy=item) Auction auction;
14. }

Given that the Auction entity maps to an AUCTION database table and the Item entity maps to an
ITEM database table, which statement is correct assuming there is NO mapping descriptor?

A - The relationship is mapped to a foreign key in the ITEM table.
B - The relationship is mapped using a join table AUCTION_ITEM.
C - The relationship is mapped to a foreign key in the AUCTION table.
D - The relationship is mapped to foreign keys in both ITEM and AUCTION tables.

Answer: C

Question: 77
Which two APIs must an EJ B 3.0 container make available to enterprise beans at runtime?
(Choose two.)

A - The J XTA 1.1 API
B - The MIDP 2.0 API
C - The J ava SE 6 API
D - The J ava SE 5 J NDI API
E - The J ava SF 5 J DBC API

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 26 of 61


Answer: D, E

Question: 78
Which component can use a container-managed entity manager with an extended persistence
context?

A - any EJ B component
B - only stateful session beans
C - only stateless session beans
D - session beans and web components

Answer: B

Question: 79
A developer writes a session bean which uses several configurable constants. The constants are
all defined as String types in J NDI. This cannot be changed because existing code is using the
same J NDI information. One of the constants is a date, represented in string format. This date
constant is used in multiple business methods of this session bean, actually as a Date object.
Converting strings to dates is an expensive operation: therefore, the developer wants to do as
little converting as possible.

Which two scenarios can be used to prevent converting from String to Date in every business
method? (Choose two,)

A - Load the date string in an instance Date type variable by annotation of the instance variable
and let the container auto convert it to a Date type automatically.
B - Load the date string in an instance String type variable by annotation of this instance variable
and convert it to a Date type object in the beans constructor.
C - Load the date string in an instance String type variable by annotation of this instance variable
and convert it to a Date type object in a @PostConstruct annotated method.
D - Load the date string in an instance Date type variable by annotation of a setter method that
takes a String and which carries out the conversion and assigns the value to the instance
variable.

Answer: C, D

Question: 80
Which two are restrictions of beans with bean-managed transactions? (Choose two.)

A - The NOT_SUPPORTED transaction attribute must be chosen.
B - Clients calling with a transactional context are prohibited and will result in an exception.
C - A stateful session bean must commit a started transaction before a business method returns.
D - A bean that starts a transaction must complete the transaction before it starts a new
transaction.
E - A message-driven bean instance must commit a transaction before the onMessage method
returns.

Answer: D, E

Question: 81
The syntax of the ORDER BY clause is defined in the J ava Persistence API as:
orderby_clause ::=ORDER BY orderby_item {, orderby_item}*

Which statement is correct about the use of ORDER BY clauses?

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 27 of 61


A - Only literals can be specified as an orderby_item.
B - Fields or properties of any type can be specified as an orderby_item.
C - The ordering must be specified if two or more orderby_item methods are provided.
D - If two orderby_item methods are provided the left orderby_item has the higher precedence.

Answer: D

Question: 82
A developer is declaring a persistent entity that will be passed as a detached object through a
remote interface to an application client. Which two characteristics must the corresponding
persistent entity class have? (Choose two.)

A - implement serializable
B - include a no-arg constructor
C - make instance variables public
D - implement the remote interface

Answer: A, B

Question: 83
Given the following entity class:

11. @Entity public class Customer {
12. @ld private int id;
13. private transient String name;
14. private java.math.BigDecimal grossAmmount;
15. }

Which mapping annotation can be added to the fields of this entity?

A - @Column to the name field
B - @Embedded ld to the id field
C - @Basic to the gross Amount field
D - @J oinColumns to the gross Amount field

Answer: C

Question: 84
A developer is writing client code for an EJ B 3.0 message-driven bean that is listening on a J MS
queue. Which statement is true?

A - The transaction context of the client is propagated to the bean.
B - If the bean instance crashes the client will need to resend all pending requests.
C - The client can call the bean method annotated with @Remove to remove the message-driven
bean instance.
D - Requests sent by the client while the EJ B server is down are processed by the bean after
restarting the server.

Answer: D

Question: 85
A developer creates the following session bean:

10. @Stateless
11. @RolesAllowed(SECRET)
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 28 of 61


12. public class MyBean implements Myinterface
13. public void methodA() {}
14. @PermitAll
15. public void methods() {}
16. @DenyAll
17. public void methodC() {}
18. }No deployment descriptor is supplied.

Which two statements are true? (Choose two.)

A - A user in the role SECRET will be able to access all of the methods.
B - A user in the role FOO will be able to access method A and methodB.
C - A user without any role will be able to access methodB but NOT methodA.
D - A user in the role SECRET will be able to access methodA and methods.
E - A user in the role SYSADM will be able to access methodA, methods, and methodC.

Answer: C, D

Question: 86
A developer implements a system in which transfers of goods are monitored. Each transfer needs
a unique ID for tracking purposes. The unique ID is generated by an existing system which is also
used by other applications. For performance reasons, the transaction that gets the unique ID
should be as short as possible. The scenario is implemented in four steps which are implemented
in four business methods in a CMT session bean:

1 .checkGoods Checks goods in a database
2.getUniqueld Retrieve the unique ID
3.checkAmount Checks the amount in a non-transactional system
4.storeTransfer Stores the transfer in a database as part of the calling transaction.

These methods are called by the addTransfer method of a second CMT session bean in the
following order:

checkGoods, getUniqueld, checkAmount, storeTransfer

Assuming no other transaction-related metadata, which is the correct set of transaction attributes
for the methods in the session beans?

A - 0.addTransfer REQUIRED
1.checkGoods REQUIRED
2.getUniqueld REQUlRES_NEW
3.checkAmountsNOT_SUPPORTED
4.storeTransferMANDATORY
B - 0.addTransfer REQUlRED
1.checkGoods REQUIRED
2.getUniqueId REQUlRED
3.checkAmounts REQUlRED
4.storeTransfer REQUlRED
C - 0.addTransfer REQUIRED
1.checkGoods REQUIRED
2.getUniqueId REQUIRES_NEW
3.check Amounts NEVER
4.storelransterMANDAToRY
D - 0.addTransterNOT_SUPPORTED
1.checkGoods REQUIRED
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 29 of 61


2 .getUniqueId REQUIRED
3 .checkmountsNOT_SUPPORTED
4.storeTransferMANDATORY

Answer: A

Question: 87
A developer writes a stateful session bean with local business interface Bar containing method
test. Method test is implemented as:

11. @Remove
12. public void test() {}

A business method in a stateless session bean invokes a reference to bean Bar as follows:

11. @EJ B Bar bar;
12.
13. public void foo() {
14. bar.test();
15. bar.test();
16. }

Assuming execution reaches Line 15, what is the expected result?

A - Method foo returns without error.
B - A javax.ejb.NoSuchEJ BException is thrown.
C - A java.rmi.NoSuchObjectException is thrown.
D - A javax.ejb.NoSuchEntityException is thrown.

Answer: B

Question: 88
A developer has obtained a container-managed entity manager in a stateless session bean.
Which two statements are correct? (Choose two.)

A - Invoking the flush method without a transaction will throw an exception.
B - Invoking the clear method without a transaction will throw an exception.
C - Invoking the persist method without a transaction will throw an exception.
D - Invoking the find method for an entity that does NOT exist will throw an exception.

Answer: A, C

Question: 89
The J ava Persistence entity Lineltem defines a composite primary key that is defined by the two
columns ORDERID and LINEITEMID in the database. Which two are true? (Choose two.)

A - Lineltem must define a primary key class to represent the composite primary key.
B - The composite primary key is mapped as two fields in Lineltem. No extra primary key class is
necessary.
C - The combination of @Embedded and @Embeddable annotations can be used to denote the
composite primary key.
D - The semantics of the equals and hashCode methods of the primary key class must be
consistent with the database equality.

Answer: A, D
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 30 of 61



Question: 90
Which two annotations can be applied at the class, method, and field levels? (Choose two.)

A - @EJ B
B - @lnit
C - @Resource
D - @RolesAllowed
E - @PostActivate

Answer: A, C

Question: 91
A User entity is in a one-to-many relationship with a Book entity. Assume that a developer has a
function fetchBook(String title) that fetches a Book entity with the given title title. Also assume that
the developer has an entity manager em. Which query can be used to return the user that holds
the book titled J ava?

A - em.createQuery(SELECT u FROM User u where :great IN
u.books.title).setParameter(great,J ava)
B - em.createQuery(SELECT u FROM User u where :great IN
u.books).setParameter(great,fetchBook(J ava))
C - em.createQuery(SELECT u FROM User u where great MEMBER OF
u.books.title).setParameter(great,J ava)
D - em.createQuery(SELECT u FROM User u where :great MEMBER OF
u.books).setParameter(greatfetchBook(J ava))

Answer: D

Question: 92
A developer writes client code that runs in a J ava EE container and accesses an EJ B 3.0 stateful
session bean. Which three statements are correct? (Choose three.)

A - The client can obtain a reference to the beans business interface through J NDI lookups.
B - The client can obtain a reference to the beans business interface through dependency
injection.
C - If the client calls a business method after the bean instance has been removed an exception
will occur.
D - After obtaining a reference to the beans business interface, the client must call the create
method before it may call business methods.
E - After the bean instance has been passivated, the client needs to re-obtain a reference to the
beans business interface to activate the bean instance.

Answer: A, B, C

Question: 93
A User entity is in a one-to-many relationship with a Book entity. In other words, a developer can
reach the collection of books that a User instance myUser has by using the path expression
myUser.books. A developer wants to write a J ava Persistence query that returns all users that
have only two books. Which two are valid queries that return this information? (Choose two.)

A - SELECT u FROM User u WHERE SIZE(u.books) =2
B - SELECT u FROM User u WHERE COUNT(u.books) =2
C - SELECT u FROM User u WHERE (SELECT COUNT(LJ ) FROM u.books b) =2
D - SELECT u FROM User u WHERE (SELECT SIZE(b) FROM u.books b) =2
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 31 of 61



Answer: A, C

Question: 94
A developer needs to deliver a large-scale enterprise application that connects to legacy systems.
If the developer chooses an EJ B 3.0-compliant application server, which three are true about the
EJ B business component tier? (Choose three.)

A - Load-balancing is NOT a guarantee for all EJ B 3.0 containers.
B - Clustering is guaranteed to be supported by the EJ B 3.0 container.
C - Thread pooling can be optimized by the Bean Provider programmatically.
D - Bean Providers are NOT required to write code for transaction demarcation.
E - Support for server fail-over is guaranteed for an EJ B 3.0-compliant application server.
F - EJ B 3.0-compliant components are guaranteed to work within any J ava EE 5 application
server.

Answer: A, D, F

Question: 95
Which statement is true about the EJ B 3.0 stateful session bean?

A - Its conversational state is retained across method invocations and transactions.
B - Its conversational state is lost alter passivation unless the bean class saves it to a database.
C - Its interceptors and their instance field values are NOT part of the conversational state of the
bean.
D - Its conversational state is retained across method invocations but NOT across transaction
boundaries.

Answer: A

Question: 96
A developer wants to create a J ava Persistence query that restricts the results of an age-based
query. Specifically, the developer wants to select everyone who is NOT a teenager. (A teenager
is someone who is 13, 14, 15, 16, 17, 18, or 19 years old.) Which expression in the querys
WHERE clause is correct?

A - WHERE p.age NOT BETWEEN 12 and 20
B - WHERE p.age NOT BETWEEN 13 and 20
C - WHERE p.age NOT BETWEEN 12 and 19
D - WHERE p.age NOT BETWEEN 13 and 19

Answer: D

Question: 97
A developer writes a stateless session bean with one local business interface and with container-
managed transactions. All business methods have transaction attribute REQUIRED. The bean
has an injected field sessionCtx of the type SessionContext. Which two operations are allowed in
a business method of the bean? (Choose two.)

A - sessionCtx.getEJ BObject
B - sessionCtx.setRollbackOnly
C - sessionCtx.getMessageContext
D - sessionCtx.getBusinessObject
E - sessionCtx.getEJ BLocalObject

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 32 of 61


Answer: B, D

Question: 98
A developer implements a session bean which acts as a session facade for an application. This
means that clients will only see this session beans interface which offers the application
interface. There are three distinct roles known at development time: user, admin, and guest.
The majority of the methods will be used by role user. All methods must have role permissions
active and roles may be added or changed in the future.

Which two scenarios are correct? (Choose two.)

A - The developer annotates the bean class with @PermitAll and annotates the methods used by
role guest or admin individually.
B - The developer annotates the bean class with DenyAll and annotates the methods used by
role user, guest, or admin individually.
C - The developer defines individual method permissions for the methods used by roles user,
guest, and admin in the deployment descriptor.
D - The developer annotates the bean class with @RolesAllowed(user) and annotates the
methods used by role guest or admin individually.
E - The developer defines a method permission with method name and role user and adds
individual method permissions for the methods used by roles guest and admin in the
deployment descriptor.

Answer: D, E

Question: 99
A developer wants to achieve the following two behaviors:

(1) If a client calls a business method without a transaction context, the container will invoke the
bean in an unspecified transaction context.
(2) If a client calls a business method with a transaction context, the container will suspend the
association of the transaction context with the current thread before invoking the enterprise
beans business method.

Which transaction attribute should be used?

A - NEVER
B - REQUIRED
C - SUPPORTS
D - NOT_SUPPORTED

Answer: D

Question: 100
Which four are defined in the EJ B specification as a standard EJ B role? (Choose four.)

A - End Point Provider
B - Persistence Provider
C - Name Space Provider
D - J SF Interface Provider
E - Application Assembler
F - EJ B Container Provider
G - Enterprise Bean Provider

Answer: B, E, F, G
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 33 of 61



Question: 101
Within a J ava EE environment, which annotation can be used to inject an entity manager factory?

A - @Entity
B - @Factory
C - @J TAFactors
D - @PersistenceUnit
E - @PersistenceContext

Answer: D

Question: 102
Given:

public class MyException extends Exception {}

The business interface Foo declares a method work():

1. public void work() throws MyException;

The bean class FooBean contains the following:

10. @Stateless
11. @Remote(Foo.class)
12. public class FooBean {
13. public void work() throws MyException {
14. //do some work not shown here
15. throw new MyException();
16. }

Assuming there is no deployment descriptor, which statement is true when the work() method is
invoked by a client with an existing transaction context and execution reaches Line 15?

A - The container does not roll back the transaction.
B - The client receives javax.ejb.EJ BTransactionRequiredException.
C - The client receives javax.ejb.EJ BTransactionRolledbackException.
D - The container marks the transaction for rollback by calling the EJ BContext.setRollbackOnly
method.

Answer: A

Question: 103
A User entity is in a one-to-many relationship with a Book entity.

A developer writes a query to delete users that have a first name of Fred or Ginger, and writes
the following J ava Persistence query language statement:

DELETE FROM User u WHERE u.name IN (Fred, Ginger)

If the query fails with a PersistenceException, what can be the cause?

A - The syntax of the query is NOT correct.
B - The query causes a foreign key integrity constraint to be violated.
C - The database does NOT have any users with the name Fred or Ginger.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 34 of 61


D - The entities corresponding to the users with the name Fred or Ginger are already being
managed by the persistence context.

Answer: B

Question: 104
A stateful session bean contains a number of instance variables. The types of instance variables
A and B are NOT serializable. Instance variable B is a complex type which is populated by many
business calls, and can, therefore, NOT be refilled by the client without starting all over. A helper
instance variable C is defined as having a Serializable type, and can hold all the information
which is in variable B. For example, B is of type XML-DOM Tree and C of type String.

Which two solutions, when combined, maintain the state of the session bean over a passivation
and activation by the container? (Choose two.)

A - The value of helper variable C is used to create the value of instance variable B in the beans
no-arg constructor.
B - The value of helper variable C is used to create the value or instance variable B in a
@PostCreate annotated method.
C - The value of helper variable C is used to create the value of instance variable Bin a
@PostActivate annotated method.
D - Instance variable A must be made null and instance variable B must be converted to a
Serializable type and assigned to another instance variable in a PreDestroy annotated
method.
E - Instance variable A must be defined transient. Instance variable B must be converted to a
Serializable type, set to null, and assigned to the instance variable C in a @PrePassivate
annotated method.

Answer: C, E

Question: 105
A developer is designing a J ava Persistence application that is mapped to a set of existing tables.
This set includes table EMPLOYEE, DEPARTMENT, and PROJ ECT. Tables EMPLOYEE and
DEPARTMENT do NOT define any foreign key constraints to table PROJ ECT. Table PROJ ECT
defines foreign key constraints with references to tables EMPLOYEE and DEPARTMENT and an
extra column called COST. The table EMPLOYEE is mapped to an entity Employee and the table
DEPARTMENT to an entity Department.

How can the table PROJ ECT be mapped so the persistence application can be portable?

A - Such sets of tables cannot be mapped and keep the application portable.
B - Map the table PROJ ECT as a secondary table for either the Employee or Department entity.
C - Map the table PROJ ECT to bidirectional many-to-many relationships between the Employee
and Department using a java.util.Map as the type of the field or property.
D - Map the table PROJ ECT to an entity Project with a field or property cost mapped to the
column COST and one-to-many relationships to this entity in the Employee and the
Department.

Answer: D

Question: 106
Which statement about message-driven beans is correct?

A - Each message-driven bean instance will be invoked only one thread at a time.
B - When dispatching messages to message bean instances the container must preserve the
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 35 of 61


order in which messages arrive.
C - ha message-driven bean is associated with a J MS queue, each bean instance in the pool will
receive each message sent to the queue.
D - It a message-driven bean is associated with a J MS durable subscription, each bean instance
in the pool will receive each message sent to the durable subscription.

Answer: A

Question: 107
A developers objective is to end the persistence context associated with an application-managed
entity manager. Which statement is correct?

A - Invoke the flush method of the entity manager.
B - Invoke the close method of the entity manager.
C - Invoke the clear method of the entity manager.
D - Invoke the remove method of the entity manager.

Answer: B

Question: 108
Which two capabilities are legal for an enterprise bean? (Choose two.)

A - being a socket client
B - updating a static field
C - starting a separate thread
D - listening on a server socket
E - interrupting all the threads in a thread group
F - using the java.lang System .currentTimeMillis method

Answer: A, F

Question: 109
Given the following stateful session bean:

10. @Stateful
11. public class VideoBean implements Video {
12. public void methodA() {}
13.
14. @TransactionAttribute(TransactionAttributeType SUPPORTS)
15. public void methodB() {}
16.
17. public void methodC () {}
18. @TransactionAttribute(TransactionAttributeType REQUIRED)
19.
20. public void methodD() {}
21. }

Assuming no other transaction-related metadata, which is true?

A - methodB and methodC have transaction attribute SUPPORTS, while methodD has
transaction attribute REQUIRED.
B - methodA and methodC have transaction attribute REQUIRES_NEW, while methodB has
transaction attribute SUPPORTS.
C - methodC, methodD, and methodA have transaction attribute REQUIRED, and methodB has
transaction attribute SUPPORTS.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 36 of 61


D - methodB has transaction attribute SUPPORTS, methodD has transaction attribute
REQUIRED, and methodA and methodC have transaction attribute REQUIRES_NEW.

Answer: C

Question: 110
A J ava Persistence application uses entities mapped to tables from two datasources in the same
transaction. What statement is correct?

A - This is NOT possible.
B - The entities must be packaged into two persistence units.
C - The entities can be packaged into a single persistence unit
D - The entities must be packaged using two different persistence.xml files.

Answer: B

Question: 111
A Deployer is given the following session bean:

10. @Stateless
11. @RolesAllowed(BATH)
12. @DeclareRoles(SOAP)
13. public class ShowerBean implements Shower {
14. public void plug() {}
15. }

and the following associated excerpt from the ejb-jar.xml descriptor file:

20. <assembly-descriptor>
21. <security-role>
22. <role-name>TOWEL</role-name>
23. </security-role>
24. </assembly-descriptor>

Which roles is the Deployer expected to map to users or user groups?

A - TOWEL
B - BATH and SOAP
C - BATH and TOWEL
D - BATH and SOAP and TOWEL

Answer: D

Question: 112
A J ava EE 5 application contains a session bean which uses a security role USER. A group
called people is defined in an LDAP server. Which two define appropriate EJ B role
responsibilities? (Choose two.)

A - The Deployer defines and configures the LDAP realm.
B - The system administrator defines and configures the LDAP realm.
C - The Deployer maps the application role USER to the LDAP group people.
D - The system administrator maps the application role USER to the LDAP group people.

Answer: B, C

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 37 of 61


Question: 113
The J ava Persistence API defines EntityTransaction interface. Which statement is correct?

A - It is used to control transactions on J TA entity managers.
B - It is used to control transactions on resource-local entity managers.
C - All methods of this interface will throw IllegalstateException if a transaction is NOT active.
D - Calling getTransaction method on a closed entity manager will throw an IllegalstateException.

Answer: B

Question: 114
Which statement is correct about a J ava EE client of a message-driven bean?

A - The client can use J NDI to obtain a reference to a message destination.
B - The client can use J NDI to obtain a reference to a dependency injection.
C - The client can use J NDI to obtain a reference to a message-driven bean instance.
D - The client can use J NDI to look up a reference to the message-driven beans home interface.

Answer: A

Question: 115
Which option will a developer use to obtain a MessageDrivenContext in a message-driven bean
class written to the EJ B 3.0 API?

A - Implement the MessageDrivenBean interface.
B - Specify MessageDrivenContext as a constructor parameter.
C - Declare a dependency on the MessageDrivenContext interface.
D - Specify MessageDrivenContext as a parameter of the onMessage method.

Answer: C

Question: 116
A developer writes a stateful session bean FooBarBean with two local business interfaces Foo
and Bar. The developer wants to write a business method called getBar for interface Foo that
returns a Bar reference to the same session bean identity on which the client invokes getBar.

Which code, when inserted on Line 12 below, implements the getBar method with the wanted
behavior?

10. @Resource SessionContext sessionCtx;
11. public Bar getBar()
12.
13. }

A - return (Bar) this;
B - return (Bar) new FooBarBean();
C - return (Bar) sessionCtx.lookup(FooBarBean)
D - return (Bar) sessionCtx.getBusinessObject(Bar.class);
E - lnitialContext ic =new lnitialContext();
return (Bar) ic.lookup(java:comp/env/ejb/FooBarBean);

Answer: D

Question: 117
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 38 of 61


A developer is creating a long-running J ava Persistence reporting application that accesses a set
of related entities. The application is NOT expected to add, change, or remove records in the
database but the data can be changed by another application running on the same database.

Which option will guarantee that the report does NOT contain stale data?

A - Call the EntityManager flush API before preparing the report.
B - Call the EntityManager createQuery API before preparing the report.
C - Call the EntityManager clear API before accessing the fields or properties of the entities used
in the report.
D - Call the EntityManager refresh on each parent entity that is added to the report, and specify
cascade=REFRESH on all corresponding relationships.

Answer: D

Question: 118
A developer examines a list of potential enterprise applications and selects the most appropriate
technologies to use for each application. For which two applications is EJ B 3.0 an appropriate
solution? (Choose two.)

A - to render a GUI for mobile clients
B - as a container for web-tier components including J SP
C - as a Web service endpoint accessed by non-J ava clients
D - to receive and respond to HTTP Post requests directly from a web browser
E - as an online shopping cart which can persist across multiple sessions with a single client

Answer: C, E

Question: 119
You have been asked to develop business methods for an enterprise bean to fulfill the following
objective:

If the J DBC connection is NOT available, the current state of the shopping cart session must be
serialized.
A serialized state must be written to a text file using a java.io.PrintWriter.
Data must be shared with a Web services end point.
Logging information must be displayed in a javax.swing.J Panel component.

Which is true?

A - The requirements can be fulfilled only in session beans.
B - The requirements can be fulfilled only in message-driven beans.
C - All of the requirements can be fulfilled using either session beans or message-driven beans.
D - None of the requirements can be fulfilled using either session beans or message-driven
beans.
E - Both session beans and message-driven beans can fulfill some but not all of the
requirements.

Answer: E

Question: 120
A developer creates a stateless session bean. This session bean needs data from a remote
system. Reading this data takes a long time. Assume that the data will NOT change during the
lifetime of the bean and that the information to connect to the remote system is defined in J NDI.

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 39 of 61


Which statement describes how to manage the data correctly?

A - Read the data in the beans constructor.
B - The data can only be read in the beans business methods.
C - Read the data in a method which is annotated with @PrePassivate.
D - Read the data in a method which is annotated with @PostActivate.
E - Read the data in a method which is annotated with @PostConstruct.

Answer: E

Question: 121
Given the following code snippet of an EJ B 3.0 entity class:

10. @Entity
11. @Table(name=ORDERS)
12. public class Order {.... }

A developer wants to change the name of the database table for the Order entity from ORDERS
to CUSTOM, without changing the J ava source code file.

Which option can the developer use?

A - Override the name using the table sub element within the persistence units persistence.xml
file.
B - This is NOT possible in a portable EJ B 3.0 application. The only way to change the table
name is to change the J ava source code file.
C - Add a custommapping.xml file to the persistence unit, override the name using the table
sub element, and declare custommapping.xml in the mapping-file element in orm.xml.
D - Add a custommapping.xml file to the persistence unit, override the name using the table
sub element, and declare custommapping.xml in the mapping-file element in persistence.xml.

Answer: D

Question: 122
Given:

9. @Stateful
10. TransactionManagement(TransactionManagementType.BEAN)
11. public class FacadeBean implements Faade {
12. @EJ B Business business; @Resource SessionContext ctx;
13. public void startstuff() throws Exception
14. ctx.getUserTransaction.begin();
15. business.doA();
16. business.doB();
17. }
18. public void endStuff() throws Exception {
19. ctx.getUserTransaction.commit();

11. @Stateless
12. public class BusinessBean implements Business {
13. @Resource SessionContext ctx;
14. public void doA() {ctx.setRollbackOnly(); }
15. @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
16. public void doB() {}

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 40 of 61


A client calls startstuff and endstuff subsequently. Assuming NO other transaction-related
metadata, which two statements are correct? (Choose two.)

A - Method doB is never called.
B - The transaction in method doB is committed.
C - The transaction in method doB is rolled back.
D - An exception is thrown when calling method endStuff.
E - An exception is thrown when calling method startStuff.

Answer: B, D

Question: 123
Which example of J ava Persistence identity definitions is portable and correct assuming NO
mapping descriptor is present?

A - @Entity public class A {
@ld private float id;
// more code here
}
B - @ldClass(com.acme.LineltemPK.class)
@Entity
public class Lineltem {
@ld int orderld;
@ld int lineltemld;
// more code here
}
C - Entity public class Project {
@ld @GeneratedValue(strategy=TABLE)
public String getProjectld() {return pid;}
// more code here
}
D - Entity
public class Employee {
@ld public java.util.Date getBirthday() {return bday;}
// more code here
}

Answer: B

Question: 124
Given this code snippet from a J MS message-driven bean class X:

11. public X() ( System.out.print(1); }
12. public void onMessage(Message m) throws java.rmi.RemoteException {
13. try {
14. TextMessage tm =(TextMessage) m;
15. String text =tm.getText();
16. System.out.print(2);
17. }catch (J MSException e) {
18. throw new java.rmi.RemoteException()
19. }
20. }

When this bean class handles a message, which is correct?

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 41 of 61


A - After a message delivery the result is 1.
B - After a message delivery the result is 2.
C - After a message delivery the result is 1 2.
D - After a message delivery an exception is thrown.
E - After a message delivery the result is unpredictable.
F - This is NOT an EJ B 3.0 compliant bean.

Answer: F

Question: 125
Which two statements are true about EJ B 3.0 session bean transaction management? (Choose
two.)

A - All session beans in the same ejb-jar must have the same transaction demarcation type.
B - All session beans in the same enterprise application archive must have the same transaction
demarcation type.
C - Session beans with bean-managed transaction demarcation cannot participate in a two-phase
commit procedure.
D - Session beans with bean-managed transaction demarcation can use transactional resources
managed by the container.
E - Session beans that invoke javax.persistence.EntityManager can use either container-
managed transaction demarcation or bean-managed transaction demarcation.

Answer: D, E

Question: 126
A developer has created an application-managed entity manager. Which statement is correct?

A - A new persistence context begins when the entity manager is created.
B - A new persistence context begins when a new J TA transaction begins.
C - A new persistence context begins when the entity manager is invoked in the context of a J TA
transaction.
D - A new persistence context begins when the entity manager is invoked in the context of a
resource-local transaction.

Answer: A

Question: 127
The execution of the find method in the following code throws an exception:

11. em.find(Customer.class, custld);
12. //Where em is a reference to a extended scoped entity manager.

Which scenario can cause the exception?

A - The find method was called without a transaction.
B - The entity corresponding to the requested primary key has been removed.
C - The entity corresponding to the requested primary key has been detached
D - The data type of custld is NOT a valid type for the Customer entity primary key.

Answer: D

Question: 128
Which two statements are true about EJ B 3.0 J MS message-driven beans? (Choose two.)

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 42 of 61


A - The developer can use J MS message selector declarations to restrict the messages that the
bean receives.
B - The developer can associate the bean with a specific queue or topic using the resource-ref
element of the deployment descriptor.
C - To achieve concurrent processing of more than one message at a time, more than one bean
class must be associated with the same J MS queue.
D - The developer can use the activationConfig element of the MessageDriven annotation to
specify whether the bean should be associated with a queue or a topic.

Answer: A, D

Question: 129
A developer is writing a stateless session bean that is obtaining a transaction-scoped entity
manager using injection and assumes the application defines one persistence unit. Which
declaration is correct?

A - @Resource EntityManager em;
B - @PersistenceUnit EntityManager em;
C - @PersistenceContext EntityManager em;
D - @PersistenceUnit(TransactionScoped) EntityManager em;

Answer: C

Question: 130
An enterprise developer needs to modify the order of interceptor method execution specified by
the Bean Provider, but does NOT have access to the beans source code. No deployment
descriptor was provided in the ejb-jar delivered by the Bean Provider. Which represents the
solution to this problem?

A - No solution is possible under these conditions.
B - The Deployer can add metadata annotations to the ejb-jar.
C - The Application Assembler can add metadata annotations to the ejb-jar.
D - The System Administrator can add interceptor binding information at runtime, using vendor-
specific tools.
E - The Application Assembler can add a deployment descriptor to the ejb-jar that includes
interceptor binding information.

Answer: E

Question: 131
A developer wants to implement a relationship between Company and Department entity classes.
Every department belongs to one company, and one company has several departments. In this
application it is essential to quickly determine which company a department belongs to and to
also easily access all departments of a given company. Which two declarations provide a solution
to these requirements? (Choose two.)

A - In class Department:
@ManyToOne
private Company company;
B - In class Department
@OneToMany
private Company company;
C - In class Department:
@OneToMany(mappedBy=department)
private Collection<Company>companies;
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 43 of 61


D - In class Company:
@ ManyToOne(mappedBy=company)
private Collection<Department>departments;
E - In class Company:
@OneToMany(mapped By=company)
private Collection<Department>departments;

Answer: A, E

Question: 132
Which two are true about EJ B 3.0 exception classes? (Choose two.)

A - The javax.ejb.NoSuchEJ BException is an application exception.
B - The javax.ejb.EJ BException extends java.lang.RuntimeException.
C - The javax.ejb.EJ BTransactionRequiredException is an application exception.
D - An application exception must NOT be a subclass of java.rmi.RemoteException.
E - The javax.ejb.EJ BTransactionRolledbackException is an application exception.
F - Any subclass of java.lang.RuntimeException is always considered a system exception.

Answer: B, D

Question: 133
Which statement about the J oinTable annotation is true?

A - It must be applied to a unidirectional many-to-one association.
B - It can be applied to the owning side of a many-to-many association.
C - It must be applied to the owning side of a unidirectional one-to-many association.
D - It the name attribute is not specified it is derived from the names of the primary keys of the
two
entities involved in the association.

Answer: B

Question: 134
A CMT session bean named MrBean contains a method storeStuff which is annotated as follows:

22. @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
23. public void storeStuff()

All other methods of this bean have no transaction annotations.

Given the following part of an ejb-jar.xml:

23. <container-transaction>
24. <method>
25. <ejb-name>MrBean</ejb-name>
26. <method-name>*</method-name>
27. </method>
28. <transaction-attribute>NotSupported</transaction-attribute>
29. </container-transaction>

Which statement is correct about the methods in MrBean?

A - All methods of MrBean have transaction attribute REQUIRED.
B - All methods of MrBean have transaction attribute NOT_SUPPORTED.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 44 of 61


C - Method storeStuff has transaction attribute REQUIRES_NEW and the other methods have
transaction attribute REQUIRED.
D - Method storeStuff has transaction attribute NOT_SUPPORTED and the other methods have
transaction attribute REQUIRED.
E - Method storeStuff has transaction attribute REQUIRES_NEW and the other methods have
transaction attribute NOT_SUPPORTTED.

Answer: B

Question: 135
Which two statements about the EJ BContext.isCallerlnRole method are correct? (Choose two.)

A - Message-driven beans must NOT call the isCallerlnRole method.
B - The isCallerlnRole method may be called in a session bean constructor.
C - The isCallerlnRole method can be called in any business method of a stateless or a stateful
session bean.
D - The isCallerlnRole method can be called in the PostConstruct and PreDestroy lifecycle
callback methods of a stateless session bean.

Answer: A, C

Question: 136
J ava Persistence application uses a Version attribute to manage concurrent updates. Which is
true?

A - The Version attribute must have a public access type.
B - The Version attribute is used by the persistence provider.
C - A separate Version attribute must be specified for each class in the inheritance hierarchy.
D - A separate Version column must be specified for each table mapped to the entity.

Answer: B

Question: 137
A developer is required to declare a persistent entity named Truck to map to a database table
VEHICLE. Which entity class declaration is correct, assuming there is NO mapping descriptor?

A - 1. @Entity(name=VEHICLE) public class Truck {
2. @ld int vehld;
3. double payload;
4. }
B - 1. @Entity(table=VEHICLE) public class Truck {
2. @ld int vehld;
3. double payLoad;
4. }
C - 1. @Embedded @Table(VEHICLE) public class Truck {
2. @ld int vehld;
3. double payload;
4. }
D - 1. Entity @Table(name=VEHICLE) public class Truck {
2. @ld int vehld;
3. double payload;
4. }

Answer: D

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 45 of 61


Question: 138
Session bean A is a client of session bean B. Bean A is using container-managed transactions
and Bean A invokes a business method of bean B. Under which two circumstances does bean A
know for certain that continuing the transaction is fruitless? (Choose two.)

A - Bean A receives an application exception.
B - Bean A receives a java.rmi.RemoteException.
C - Bean As invocation of UserTransaction.getStatus returns false.
D - Bean As invocation of EJ BContext.setRollbackOnly returns true.
E - Bean A receives a javax.ejb.EJ BTransactionRolledbackException.

Answer: D, E

Question: 139
EJ B 3.0 containers must provide a specific subset of which two APIs? (Choose two.)

A - J SP APIs
B - J avaMail APIs
C - J AX-WS APIs
D - J ava Card APIs
E - Sun Studio APIs

Answer: B, C

Question: 140
Which two statements are correct about EJ B 3.0 stateful session beans and stateless session
beans? (Choose two.)

A - Both can have multiple remote and local business interfaces.
B - Both can be passivated by the EJ B container to preserve resources.
C - Both can choose to implement the javax.ejb.SessionSynchronization interface.
D - Only the stateful session bean class is required to implement java.io.Serializable.
E - Both bean classes can have the field injection of javax.persistence.EntityManager.

Answer: A, E

Question: 141
Which statement is true about the use of a persist operation in a transaction?

A - If a user persists a detached object it always becomes managed.
B - The persist operation on an entity always cascades to its related entities.
C - If a user persists a new entity with an existing primary key the transaction will fail.
D - If a user persists a managed entity an exception may be thrown by the persist operation.

Answer: C

Question: 142
A developer writes a stateless session bean FooBean with one remote business interface
FooRemote containing one business method too. Method too takes a single parameter of
application-defined type MyData.

11. public class MyData implements java.io.Serializable
12. int a;
13. }

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 46 of 61


Method foo is implemented within the FooBean class as:

11. public void foo(MyData data) {
12. data.a=2;
13. }

Another session bean within the same application has a reference to FooRemote in variable
fooRef and calls method too with the following code:

11. MyData data =new MyData();
12. data.a=1;
13. fooRef.foo(data);
14. System.out.println(data.a);

What is the value of data.a when control reaches Line 14 of the client?

A - 0
B - 1
C - 2
D - either 1 or 2

Answer: B

Question: 143
Which statement about the @MappedSuperclass annotation is correct?

A - A class annotated with @MappedSuperclass must be abstract.
B - Subclasses of entity classes cannot be annotated with @MappedSuperclass.
C - A class annotated with @MappedSuperclass has no separate table defined for it.
D - A class annotated with @MappedSuperclass can be the target of queries like any other entity
class.

Answer: C

Question: 144
XYZ Software develops business components using both the EJ B 2.1 and EJ B 3.0 APIs. Some
customers are reluctant to completely migrate to the EJ B 3.0 model, but are willing to have EJ B
2.1 session beans invoke EJ B 3.0 session beans. How should XYZ Software enhance these
components to meet this customer requirement?

A - Use @EJ B to inject a reference to the EJ B 3.0 business interface into the EJ B 2.1 bean class.
B - Use <ejb-ref>in ejb-jar.xml for the EJ B 2.1 bean to declare a reference to the EJ B 3.0
business interface.
C - Add an EJ B 3.0-style business interface to EJ B 2.1 beans to achieve interoperability between
EJ B 2.1 and EJ B 3.0 beans.
D - Use @RemoteHome and @LocalHome to adapt EJ B 3.0 beans so that EJ B 2.1 beans can
look up the adapted home interfaces using J NDI.

Answer: D

Question: 145
Which three roles will typically edit an ejb-jar? (Choose three.)

A - Deployer
B - EJ B Server Provider
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 47 of 61


C - Persistence Provider
D - System Administrator
E - Application Assembler
F - Enterprise Bean Provider

Answer: A, E, F

Question: 146
A developer is working with an entity User, which has an identity field and a salary field. Which
J ava Persistence query will return those users with the highest salaries?

A - SELECT u FROM User u WHERE u.salary >=ALL (SELECT d.salary FROM User d)
B - SELECT u FROM User u WHERE u.salary >=ANY (SELECT d.salary FROM User d)
C - SELECT u FROM User u WHERE ALL(u.salary>=(SELECT d.salary FROM User d))
D - SELECT u FROM User u WHERE u.salary >=(SELECT ALL(d.salary) FROM User d)

Answer: A

Question: 147
Given:

A stateless session beans business method invokes EJ BContext.setRollbackOnly and receives
an IllegalStateException.

Under which of these conditions could this be possible?

A - The business method is marked with the MANDATORY transaction attribute.
B - The business method is marked with the NOT_SUPPORTED transaction attribute.
C - This is NOT possible; a stateless session bean cannot invoke EJ BContext.setRollbackOnly.
D - The bean has no metadata (in annotations or deployment descriptor) which specifies the
transaction attribute for the method.

Answer: B

Question: 148
A J ava Persistence application has been developed for a J ava SE environment and the
persistence xml file looks like this:

<persistence-unit name=OrderManagement
transaction-type=RESOURCE_LDCAL>
<mapping-file>order-mappings.xml</mapping-file>
<class>com.acme.Order</class>
<class>com.acme.Customer</class>
<class>com.acme.ltem</class>
<properties>
<property name=com.acme.persistence.monitoring value=ON/>
</properties>
</persistence-unit>

Now the developer wants to repackage it as a J ava EE application and try it on several compliant
J ava EE 5 containers using injection to get an entity manager.

Which change is needed to make to the persistence.xml?

A - Specify the J TA datasource.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 48 of 61


B - Remove the transaction type attribute.
C - Remove the vendor-specific properties.
D - Remove the list of all managed classes.

Answer: B

Question: 149
An Application Assembler is given the following stateless session bean:

10. @Stateless public class MyBean implements Mylnt {
11. @RolesAllowed(SECRET)
12. public void methodA(int x) {}
13. public void methodA(String y) {}
14. public void methodB(String z) {}
15. }

A deployment descriptor is also supplied, a portion of which reads as follows:

20. <method-permission>
21. <role-name>AGENT</role-name>
22. <method>
23. <ejb-name>MyBean</ejb-name>
24. <method-name>methodA</method-name>
25. </method>
26. </method-permission>

Which statement is true?

A - A client in any role will be able to access any of the methods.
B - A client in the role AGENT will be able to access any of the methods.
C - A client in the role SECRET will be able to access any of the methods.
D - A client in the role AGENT will be able to access methodB and methodA(String), but not
methodA(int).
E - A client in the role SECRET will be able to access methodA(int) and methodB, but NOT
methodA(String).

Answer: B

Question: 150
A developer writes an enterprise application and packages it into an ear file. The application
contains two persistence units defined at the ear level with persistence unit names FooPU and
BarPU. The application also contains an ejb-jar with one stateless session bean. Which code,
when added to the stateless session bean class, injects an EntityManagerFactory at runtime?

A - @PersistenceUnit
private EntityManagerFactory emf;
B - @PersistenceContext
private EntityManagerFactory emf;
C - @PersistenceUnit(unitName=BarPU)
private EntityManagerFactory emf;
D - @Resource(name=BarPU, type=EntityManagerFactory.class)
private EntityManagerFactory emf;

Answer: C

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 49 of 61


Question: 151
Which two are true about specifying J ava EE environment annotation metadata for session bean
classes? (Choose two.)

A - It is possible to inject a resource without using annotations.
B - Only field-level annotations can be overridden by the deployment descriptor.
C - Only type-level annotations can be overridden by the deployment descriptor.
D - Resource annotations cannot be specified on a superclass of the session bean class.
E - Type-level, method-level, and field-level annotations can all be overridden by the deployment
descriptor.
F - Only field-level annotations and method-level annotations can be overridden by the
deployment descriptor.

Answer: A, E

Question: 152
Which statement is correct about the J ava Persistence API support for the SQL queries?

A - SQL queries are NOT allowed to use parameters.
B - The result of an SQL query is not limited to entities.
C - Only SELECT SQL queries are required to be supported.
D - SQL queries are expected to be portable across databases.

Answer: B

Question: 153
A developer is writing implementation code for an EJ B 3.0 message-driven bean class that
processes booking requests. Within the business logic of the onMessage method, a temporary
problem can occur. In that case the developer wants to make sure that the booking request is
processed again in 30 minutes. Which two can the developer select? (Choose two.)

A - Throw a runtime exception to roll back the transaction.
B - Call setRollbackOnly on the MessageDrivenContext interface.
C - Make use of the TimerService, and implement the TimedObject interface.
D - Make use of the TimerService, implement a reprocess method, and annotate it with
@Timeout.
E - Throw an application exception, and add the retry-after attribute to the deployment descriptor.

Answer: C, D

Question: 154
A session beans business method invokes UserTransaction.setRollbackOnly and receives an
IllegalstateException. Under which circumstance can this happen?

A - The bean is using bean-managed transactions regardless of whether there is an active
transaction.
B - There is no circumstance that would cause setRollbackOnly to throw an IllegalStateException.
C - The bean is using bean-managed transaction demarcation, and UserTransaction.begin has
NOT been invoked.
D - The setRollbackOnly method is invoked within a bean-managed transaction, and
UserTransaction.commit has NOT been invoked.

Answer: C

Question: 155
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 50 of 61


A developer maps the abstract entity class Account with concrete entity sub-classes
CreditCardAccount and SavingsAccount using the single table per class hierarchy strategy.
Which two statements are true? (Choose two.)

A - Instances of CreditCardAccount and SavingsAccount are stored in the same table.
B - All columns that correspond to fields declared in Account must be defined as null able in the
database.
C - The fields declared in Account are stored in a different table than the ones declared in
CreditCardAccount and SavingsAccount.
D - All columns that correspond to fields declared in CreditCardAccount or SavingsAccount must
be defined as null able in the database.

Answer: A, D

Question: 156
Given the following code in an EJ B 3.0 session bean:

10. @Resource(name=jdbc/employeeDB)
11. private Datasource dataSource;
12.
13. public void lookupEmployee(String id) {
14. lnitialContext ic =new InitialContext();
15. //insert code here
16. DataSource ds =(DataSource) obj;
17. }

Which code, inserted at Line 15, portably looks up the injected resource?

A - Object obj =ic.lookup(employeeDB);
B - Object obj =ic.lookup(dataSource);
C - Object obj =ic.lookup(jdbc/employeeDB);
D - Object obj =ic.lookup(java:comp/env/employeeDB);
E - Object obj =ic.lookup(java:comp/env/jdbc/employeeDB);

Answer: E

Question: 157
Which must result in the destruction of a stateful session bean?

A - A client calls an @Remove method and the method returns successfully.
B - The server in which the stateful session bean was created is restarted.
C - The stateful session bean participates in a transaction that is rolled back.
D - The stateful session bean is chosen as a last recently used (LRU) victim for passivation.

Answer: A

Question: 158
A developer writes a stateless session bean with one local business interlace and with container-
managed transactions. All business methods have transaction attribute REQUIRED. The bean
has an injected field sessionCtx of the type SessionContext. Which two operations are allowed in
a business method of the bean? (Choose two.)

A - sessionCtx.getEJ BObject
B - sessionCtx.setRollbackOnly
C - sessionCtx.getMessageContext
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 51 of 61


D - sessionCtx.getBusinessObject
E - sessionCtx.getEJ BLocalObject

Answer: B, D

Question: 159
Given the following code snippet from an EJ B 3.0 entity class:

1. package com.foo;
2. // more code here...
10. @Entity
11. @Table(name=A)
12. public class Order {

And the following excerpt from the persistence units orm.xml mapping file:

10. <entity class=com.foo.Order access=PROPERTY>
11. <table name=B/>

What is the name of the database table for Order objects?

A - A
B - B
C - A_B
D - ORDER
E - The result is unpredictable.

Answer: B

Question: 160
Which two are true about the J ava EE 5 client-view of a message-driven bean? (Choose two.)

A - References to message destinations can be injected.
B - As of EJ B 3.0, references to message destinations cannot be looked up in the clients J NDI
namespace.
C - Clients of a message destination need to know that the destination is listened to by a pool of
message consumers.
D - Clients of a message destination do NOT need to know that the destination is listened to by a
message-driven bean.

Answer: A, D

Question: 161
OldBarBean is a stateless session bean written to the EJ B 2.1 API with remote home interface.
OldBarHome and remote component interlace OldBar. FooBean is a stateless session bean
written to the EJ B 3.0 API.

OldBarBean and FooBean are the only EJ Bs packaged in the ejb-jar. The FooBean portion of the
ejb-jar.xml also declares an ejb-ref whose ejb-ref-name is ejb/oldBar. The ejb-ret is linked to
OldBarBean. There are no other ejb dependencies defined.

A business method foo in FooBean needs to access OldBarBean.

Which is portable code to achieve this goal?

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 52 of 61


A - @Remote
private OldBar oldBar;
B - public void foo() {
try{
lnitialContext ic =new InitialContext();
Object obj =ic.lookup(ejb/oldBar);
OldBarHome oldBarHome =
(OldBarHome) PortableRemoteObject.narrow(obj, OldBarHome.class);
OldBar oldBar =oldBarHome.create();
C - @EJ B private OldBarHome oldBarHome;
public void foo() {
try{
OldBar oldBar =oldBarHome.create();
D - public void foo() {
try{
lnitialContext ic =new InitialContext();
OldBarHome oldBarHome =
(OldBarHome) ic.lookup(ejb/oldBar);
OldBar oldBar =oldBarHome.create();

Answer: C

Question: 162
A developer writes a stateless session bean with a constructor, a PostConstruct method, a
PreDestroy method, and this business method:

11. public String hello() {
12. return hello;
13. }

The container invokes the hello method on an instance of the bean. Which is true about that bean
instance when control reaches Line 12?

A - The constructor has NOT been invoked.
B - The PreDestroy method has been invoked.
C - The PostConstruct method has been invoked.
D - Both the PostConstruct and PreDestroy methods have been invoked.

Answer: C

Question: 163
According to the J ava Persistence API, a managed entity instance X becomes removed by
invoking the remove method on it or when it is a target of a cascaded remove operation. Which
statement is true?

A - After an entity has been removed its state will be restored to the J ava defaults.
B - If a detached entity Y references X the IllegalstateException will be thrown.
C - If X is a new entity the remove operation is cascaded to entities referenced by K
D - A removed entity X will be guaranteed to be removed from the database when the remove
method returns.

Answer: C

Question: 164
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 53 of 61


Bean Provider has been asked to write a stateless session bean, MyBean with a single method
breakout. A System Administrator guarantees that all client accessing the bean will be identified
by mutual SSL authentication. The Bean Providers task is to ensure that breakout always logs
identity information of the client that invoked it. Which solution would satisfy this requirement?

A - Access the identity information in the X.509 certificate used to authenticate the user from
within breakout.
B - Use the getCallerPrincipal method on an injected SessionContext to determine the required
information.
C - Use the isCallerlnRole method on an injected SessionContext to determine the required
information.
D - Ensure that the breakout method is appropriately annotated with @RolesAllowed.

Answer: B

Question: 165
A developer writes two session beans which cooperate. The first session bean, ShoppingCart,
collects orders and is implemented as a stateful session bean. The second session bean,
CalculateDiscount, is implemented as a stateless session bean and runs on a different server.
ShoppingCart contains the method getTotalPrice, which calculates the total price of the order in
the ShoppingCart, including discounts. Discounts are calculated by CalculateDiscount using the
information on the ShoppingCart bean, combined with data from a database. Which scenario can
accomplish this?

A - The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean
passing the this reference.
B - The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean.
CalculateDiscount accesses the ShoppingCart instance byJ NDI lookup.
C - The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean
passing its reference obtained from the SessionContext.getBusinessObject method.
D - The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean.
CalculateDiscount accesses the state of ShoppingCart by dependency injection.

Answer: C

Question: 166
A developer is implementing an EJ B 3.0 J MS message-driven bean with bean-managed
transactions. Which two statements are true? (Choose two.)

A - The message receipt is part of the user transaction.
B - Message acknowledgement is automatically handled by the container.
C - Messages are always processed in the order they were sent to the queue
D - Two messages read from the same queue may be processed at the same time within the
same EJ B container.

Answer: B, D

Question: 167
A developer wants to create a J ava Persistence query that will include a subquery. Which three
are true? (Choose three.)

A - Subqueries can be used in a FROM clause.
B - Subqueries can be used in a WHERE clause.
C - The ANY expression can be used only with a subquery.
D - The EXISTS expression can be used only with a subquery.
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 54 of 61


E - The MEMBER expression can be used only with a subquery.

Answer: B, C, D

Question: 168
Given the method invocation sequence:

Method 1 calls Method 2
Method 2 calls Method 3
Method 1 calls Method 4

And the transaction scope:

Method 1: Transaction A
Method 2: Transaction A
Method 3: Transaction A
Method 4: Transaction B

Assuming Method 1 is invoked by a client without an existing transaction context, which set of
transaction attributes will support this scope?

A - Method 1: NEVER
Method 2: SUPPORTS
Method 3: REQUIRED
Method 4: REQUIRES_NEW
B - Method 1: REQUIRES_NEW
Method 2: MANDATORY
Method 3: SUPPORTS
Method 4: REQUIRES_NEW
C - Method 1: REQUIRES_NEW
Method 2: MANDATORY
Method 3: SUPPORTS
Method 4: SUPPORTS
D - Method 1:MANDATORY
Method 2: REQUIRED
Method 3: SUPPORTS
Method 4: REQUIRES_NEW

Answer: B

Question: 169
Given the following stateless session bean implementation classes:

10. @TransactionAttribute(TransactionAttributeType.MANDATORY)
11. public class MySuper {
12. public void methodA() {}
13. public void methodB() {}
14. }

10. @Stateless
11. public class MyBean extends MySuper implements Mylnt {
12. public void methodA() {}
13.
14. @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
15. public void methodC() {)
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 55 of 61


16. }
10. @Remote()
11. public interlace Mylnt {
12. public void methodA();
13. public void methodB();
14. public void methodC();
15. }

Assuming no other transaction-related metadata, what are the transaction attributes of methodA,
methodB, and methodC respectively?

A - MANDATORY, MANDATORY, and MANDATORY
B - REQUIRED, MANDATORY, and REQUIRES_NEW
C - MANDATORY, MANDATORY, and REQUIRES_NEW
D - REQUIRED, REQUIRES_NEW, and REQUIRES_NEW

Answer: B

Question: 170
A developer has obtained a container-managed entity manager with transaction scoped
persistence context. Assume there is no persistence context associated with the entity manager.
When does a new persistence context begins?

A - when a J TA transaction begins
B - when the entity manager is created
C - when the entity manager is invoked in the scope of an active J TA transaction
D - when the entity manager is created in the scope of an active resource local transaction

Answer: C

Question: 171
A developer wants to create a J ava Persistence query to perform a bulk update operation on five
different entity classes. All of these classes have a field called name. These classes have the
following relationships:

Harrier extends Dog and Dog extends Animal
Vet extends Doctor

What is the minimum possible number of operations required to change the value of the name
field for all of the entities in all five classes?

A - 1
B - 2
C - 3
D - 4
E - 5

Answer: B

Question: 172
Given:

10. @Stateless
11. public void SecureBean01 implements Secure01 {
23. @AllowRoles(ADMIN)
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 56 of 61


24. public void methodA() {}
10. @Stateless
11. public void Securesean02 implements Secure02 {
23. @AllowRoles(administrator)
24. public void methodB() {}

Which deployer action permits a user authenticated as J ohn to call both methodA on
SecureBean01 and methodB on SecureBean02?

A - The deployer maps both role ADMIN and role administrator to user J ohn.
B - The deployer replaces administrator by ADMIN in the source code of SecureBean02 and
maps ADMIN to user J ohn.
C - The deployer overrides the method permission of SecureBean02. methods in the ejb-jar.xml
deployment descriptor and maps ADMIN to user J ohn.
D - The deployer defines a common role and maps role ADMIN and role administrator using
security-role-ref entries to this role. This common role is mapped to user J ohn.

Answer: A

Question: 173
A developer is implementing an EJ B 3.0 message-driven bean that will be associated with a J MB
topic. The bean must NOT miss any messages published to the topic, even it the EJ B server is
down for some time. Which is correct?

A - The developer should set the activation config property subscription Durability to value
Durable.
B - The developer should set the activation config property subscription Durability to value
NonDurable.
C - Clients must take care of resending messages to the topic in case of missing message
acknowledgements.
D - The developer does NOT need to do anything, because as long as the EJ B server is down no
client can publish messages to the topic.

Answer: A

Question: 174
An enterprise developer has received ejb-jars from multiple Bean Providers and wants to
combine them into a single ejb-jar as well as altering the method permissions on some of the
beans without recompiling any of the code contained in the ejb-jar. Which is correct?

A - Bean Provider is the only role that can perform this task.
B - Deployer is the most appropriate role to perform this task.
C - Either a Deployer or System Administrator role may perform this task.
D - This problem cannot be solved using an EJ B 3.0-compliant approach.
E - Application Assembler is the most appropriate role to perform this task.

Answer: E

Question: 175
A company has a business application that allows end users to order products over the web.

A developer in the company wants to add the following capability to the application:

When the web-tier handles a new order, it should notify all the interested beans in the EJ B-tier.

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 57 of 61


To satisfy this new capability, the developer wants to use a message-driven bean and must
choose between associating it with a javax.jms.Topic destination or a javax.jms.Queue
destination.

Which two are true about this decision? (Choose two.)

A - J MS Topics are intended to be used to solve this type of scenario.
B - J MS Queues are intended to be used to solve this type of scenario.
C - Only Queue destinations allow for messages to survive a server crash.
D - Topic destination allow the developer to configure subscription durability

Answer: A, D

Question: 176
Which is the valid use of the javax.ejb Init annotation?

A - to annotate a method in a stateful session bean class so that the container will invoke it after
the EJ B is deployed and started
B - to specify the correspondence of a method on a stateful session bean with a create method of
the adapter home interfaces
C - to annotate a bean class inside the ejb-jar archive to act as a bootstrap EJ B which is loaded
into the container before any other EJ Bs
D - for a client to invoke the method annotated with @lnit to initialize a newly created stateful
session bean instance with user-specific data

Answer: B

Question: 177
An application wants to utilize side-effects of cascading entity-manager operations to related
entities. Which statement is correct?

A - The persist operation is always cascaded to related entities for one-to-one and one-to-many
relationships
B -To minimize the effect of the remove operation applied to an entity participating in a many-to-
many relationship the remove operation should be cascaded to entities on both sides of the
relationship.
C - The persist operation applied to a new entity X is cascaded to entities referenced by X if the
relationship from X to these other entities is annotated with the cascade=PERSIST or
cascade=ALL annotation element value
D - The remove operation applied to a removed entity X is cascaded to entities referenced by X if
the relationship from X to these other entities is annotated with the cascade=REMOVE or
cascade=ALL annotation element value.

Answer: C

Question: 178
A developer wants to have bookingDate stored in table BOOKING, flightNumber in table
FLIGHTBOOKING, and hotelName in table HOTELBOOKING.

Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 58 of 61




Which code, inserted at Line 11 of class Booking, is appropriate for this strategy?

A - @J oined
B - SingleTabIe
C - @TablePerClass
D - @lnheritance(strategy=J OINED)
E - @lnheritance(strategy=SlNGLE_TAbLE)
F - @lnheritance(strategy=TABLE_PER_CLASS)

Answer: D

Question: 179
Which statement about mapping using the J ava Persistence API is correct?

A - User-defined XML mapping files can be used only if orm.xml file is NOT present.
B - All mapping file other than orm.xml must be listed explicitly in the persistence.xml descriptor
C - Mapping information specified in the XML mapping tile overrides all annotations and default
mappings.
D - The orm.xml file must be placed into the persistence units root to be processed by the
persistence provider.

Answer: B

Question: 180
A developer needs to include a set of managed classes in a persistence unit. Which two solutions
are correct? (Choose two.)

A - Place the class files in the orm.xml file.
B - Place the class files in root of the persistence unit.
C - Place the class files in any mapping file that is included on the classpath.
D - Place the class files in the any jar on the classpath that is included in the persistence unit

Answer: B, D

Question: 181
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 59 of 61


A developer wants to use the J ava Persistence query language. Which two are true? (Choose
two.)

A - A WHERE clause is required in every query.
B - The WHERE clause can restrict the scope of a delete operation
C - The WHERE clause can be used to order the results returned by a query.
D - The WHERE clause is used to determine the types of objects to be retrieved from a persistent
store.
E - The WHERE clause is used to restrict the contents of a collection of objects that are returned
from a query

Answer: B, E

Question: 182
Using bean-managed transaction demarcation, under which two circumstances must the
container roll back a transaction? (Choose two.)

A - A stateful session bean invokes UserTransaction.getRollbackOnly.
B - A stateful session bean throws an uncaught application exception from a business method.
C - A stateful session bean begins a transaction in a business method but does NOT complete it
before returning.
D - A stateless session bean begins a transaction in a business method but does NOT complete
it before returning.
E - A message driven bean begins a transaction in a message listener method but does NOT
complete it before returning.

Answer: D, E

Question: 183
A developer writes a stateless session bean FooBean and uses its deployment descriptor to
declare a local ejb dependency on a stateful session bean in the same ejb-jar.

<ejb-local-ref>
<ejb-ref-name>barRef</ejb-ref-name>
<local>acme.Bar</local>
<ejb-link>BarBean</ejb-blink>
<injection-target>
<injection-target-class>acme.FooBean</injection-target-class>
<injection-target-name>bar</injection-target-name>
</injection-target>
</ejb-local-ref>

Which environment annotation. when declared within the FooBean bean class, is equivalent to
the ejb-local-ret shown above?

A - @EJ B(bean =BarBean)
private acme Bar.barRef;
B - @EJ B(name=bar, beanName=BarBean)
private acme.Bar barRef;
C - @EJ B(name=barRef, beanName=BarBean)
private acme.Bar barRef;
D - @EJ B(name=ejb/barRef, beanName=BarBean)
private acme.Bar bar;

Answer: C
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 60 of 61



Question: 184
While executing a business method in a stateless session bean the container rolls back the
methods transaction. Which three are possible causes for the containers behavior? (Choose
three.)

A - The bean uses container-managed transactions and invokes EJ BContext.setRollbackOnly.
B - The bean uses container-managed transactions and invokes EJ BContext.getRollbackOnly.
C - The business method throws an unchecked exception of a class type that is marked with the
@ApplicationException annotation with the rollback element value true
D - The business method throws a checked exception of a class type that is marked with the
@ApplicationException annotation with the rollback element value false.
E - The business method throws a unchecked exception of a class type that is marked with the
@ApplicationException annotation with the rollback element value false.
F - The bean uses container-managed transactions and throws a checked exception of a class
type that is marked with the @ApplicationException annotation with the rollback element value
false.

Answer: A, C, E

Question: 185
Given this code snippet from a J MS message-driven bean class named MyMDB:

11. public MyMDB() {System.out.print(a ); }
12. public void onMessage(Message m) {System.out.print( b ); }
13. @PreDestroy
14. public void remove() {System.out.print( c ); }

The container crashes and then restarts and then the bean class handles two messages. Which
four are possible results? (Choose four.)

A - a b b
B - a c b b
C - a a c b b
D - a a b b c
E - a b c b c
F - a b a b c c

Answer: A, C, D, F

Question: 186
Which is the correct way of declaring bean-managed transaction demarcation for an EJ B 3.0
message-driven bean?

A - @ MessageDriven
public class MyMessageBean
implements MessageListener, UserTransaction
B - @MessageDriven
@TransactionManagement(TransactionManagementType.Bean)
public class MyMessageBean implements MessageListener {
C - @MessageDriven
public class MyMessageBean implements MessageListener {
@TransactionManagement(TransactionManagementType BEAN)
public void onMessage(Message message) {.. .}
D - @MessageDriven(transactionManagement=TransactionManagementType BEAN)
Exam Name: Sun Certified Bus. Component Developer java EE Platform 5
Exam Type: Sun
Exam Code: 310-091 Total Questions: 187

Page 61 of 61


public class MyMessageBean implements MessageListener {

Answer: B

Question: 187
A developer is creating an entity which is mapped to a table that has a primary key constraint
defined on two character columns and would like to use mapping defaults as much as possible to
simplify the code. Which two mapping options can be chosen? (Choose two.)

A - Use an @ld property that constructs a private field as a concatenation of two columns.
B - Use a separate class to map those two columns and use an @ldClass annotation to denote
the primary key field or property in the entity.
C - Use a separate @Embeddable class to map those two columns and use @Embeddable
annotation to denote a single primary key field or property in the entity
D - Use a separate @Embeddable class to map those two columns and add two fields or
properties to the entity, each marked as @ld that correspond to the fields or properties in the
embeddable class.
E - Use a separate class to map those two columns. Specify that class using @ldclass annotation
on the entity class Add two fields or properties to the entity, each marked as @ld that
correspond to the fields cm properties in that separate class.

Answer: C, E

End of Document

You might also like