310-091 Sun Certified Bus. Component Developer Java EE Test Set 6

Which three statements are true about EJB 3.0 containers? (Choose three.)

A. Remote argument passing semantics conform to Java RMI-IIOP.

B. The JAXB 2.0 API is guaranteed to be available for all bean types.

C. The Java 2D API is guaranteed to be available for session beans.

D. javax.naming.InitialContext is guaranteed to provide a JNDI name space.

E. The Java 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.


Options are :

  • A,B,F
  • A,B,D
  • E,B,D
  • A,B,E

Answer : A,B,D

310-091 Sun Certified Bus. Component Developer Java EE Test Set 7

Which statement about entity manager is true?



Options are :

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

Answer : A container-managed entity manager must be a JTA entity manager.

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

10. @EJB Foo bean1;

11. @EJB 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.


Options are :

  • B,F
  • B,C
  • E,C
  • B,D

Answer : B,C

A developer is working on a project that includes both EJB 2.1 and EJB 3.0 session beans. A lot

of business logic has been implemented and tested in these EJB 2.1 session beans. Some EJB

3.0 session beans need to access this business logic.

Which design approach can achieve this requirement?



Options are :

  • Add EJB 3.0 business interfaces to existing EJB 2.1 session beans and inject references to these business interfaces into EJB 3.0 session beans.
  • Add adapted home interfaces to EJB 3.0 session beans to make EJB 3.0 and EJB 2.1 session beans interoperable.
  • No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 home interface into the EJB 3.0 bean class.
  • No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 component interface into the EJB 3.0 bean class.

Answer : No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 home interface into the EJB 3.0 bean class.

310-091 Sun Certified Bus. Component Developer Java EE Test Set 8

Which statement is true about the primary key of a Java Persistence entity?



Options are :

  • The primary key cannot be overriden by a mapping descriptor.
  • If property-based access is used, the properties of the primary key class must be public or protected.
  • 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.
  • The location of the primary key defines the topmost entity class in the hierarchy.

Answer : If property-based access is used, the properties of the primary key class must be public or protected.

Given:

11. @Entity public class X {

12. @Id int id;

13. Y y;

14. }

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

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

are provided?



Options are :

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

Answer : Class Y must be serializable.

Bean A is using bean-managed transaction demarcation and has invoked the foo method of bean

B. When the foo method returns, bean A needs to determine if the transaction has been set to

rollback. Which must be true?



Options are :

  • For this to be possible, bean B must also use bean-managed transaction demarcation.
  • Bean A must invoke the getStatus method on the UserTransaction that it began.
  • Bean A must invoke the getRollbackOnly method on the UserTransaction that it began.
  • It is NOT possible for bean A to determine if the transaction has been set to rollback.
  • Bean A must invoke the setRollbackOnly method on the UserTransaction that it began.

Answer : Bean A must invoke the getStatus method on the UserTransaction that it began.

310-091 Sun Certified Bus. Component Developer Java EE Test Set 9

Which two statements are correct? (Choose two.)

A. An EJB 3.0 message-driven bean can itself be the client of another message-driven bean.

B. The client of an EJB 3.0 message-driven bean can use the bean's remote business interface to

communicate with the bean.

C. Every client of an EJB 3.0 JMS message-driven bean must be a Java application that uses the

JMS API to communicate with the bean.

D. Messages sent to JMS topics are intended for only one receiver whereas messages sent to

JMS queues are intended for multiple receivers.

E. If the client of an EJB 3.0 message-driven bean awaits a reply to its request, the client can set

the JMSReplyTo attribute to provide routing information to the bean.


Options are :

  • A,B
  • A,C
  • A,E
  • A,D

Answer : A,E

Which two are programming restrictions in the EJB 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.InitialContext.


Options are :

  • A,D
  • B,C
  • A,C
  • A,B

Answer : A,C

Which Java Persistence query uses the aggregate function correctly, assuming that chairs field is

of type int?



Options are :

  • SELECT c FROM Chair c WHERE LOCATE (c.type, 'lazyboy') > -1
  • SELECT ANY(r.chairs) FROM Room r
  • SELECT r FROM Room r WHERE r.chairs > AVG(r.chairs)
  • SELECT NEW Integer(MAX(r.chairs)) FROM Room r

Answer : SELECT NEW Integer(MAX(r.chairs)) FROM Room r

310-110 Sun Certified Mobile Application Developer for J2ME Set 1

Which two options can be used to predefine Java 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


Options are :

  • A,B
  • A,C
  • D,C
  • A,D

Answer : A,C

A developer wants to create a portable EJB 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

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

17. }

Which statement is correct?



Options are :

  • 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.
  • The validateCreate method can invoke the EntityManager.flush operation.
  • The validateCreate method may NOT throw runtime exceptions.
  • Methods of the class com.acme.AlertMonitor annotated with callback annotations must take an Object or Account instance as the only argument.

Answer : Methods of the class com.acme.AlertMonitor annotated with callback annotations must take an Object or Account instance as the only argument.

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 inteface 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.


Options are :

  • C,D
  • C,A
  • C,B
  • A,D

Answer : C,D

310-110 Sun Certified Mobile Application Developer for J2ME Set 11

A developer wants to implement an association relationship between CarModel and

CarManufacturer. 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?



Options are :

  • In CarModel class, declare an attribute of type Collection and annotate it with @ManyToOne.
  • In CarManufacturer class, declare an attribute of type CarModel and annotate it with @OneToMany.
  • In CarModel class, declare an attribute of type CarManufacturer and annotate it with @OneToMany.
  • In CarModel class, declare an attribute of type CarManufacturer and annotate it with @ManyToOne.
  • In CarManufacturer class, declare an attribute of type Collection and annotate it with @OneToMany.

Answer : In CarModel class, declare an attribute of type CarManufacturer and annotate it with @ManyToOne.

Which is a valid PostConstruct method in a message-driven bean class?



Options are :

  • @PostConstruct private static void init() {}
  • @PostConstruct public static void init() {}
  • @PostConstruct private void init() {}
  • @PostConstruct public boolean init() { return true; }

Answer : @PostConstruct private void init() {}

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



Options are :

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

Answer : Bean instances are NOT required to survive container crashes.

310-110 Sun Certified Mobile Application Developer for J2ME Set 12

Given the following statements about an EJB deployment descriptor for which the metadatacomplete

attribute is not specified:

I. The EJB deployment descriptor can provide additional metadata to bean class annotations.

II. The EJB deployment descriptor can partially override bean class annotations.

III. The EJB deployment descriptor can entirely override bean class annotations.

Which is true?



Options are :

  • Both statements I and III are correct.
  • Both statements I and II are correct.
  • Only statement I is correct.
  • Only statement III is correct.
  • Only statement II is correct.

Answer : Both statements I and II are correct.

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?



Options are :

  • The method will return TRUE.
  • The method will throw an exception.
  • The Order instance will be removed from the database.
  • The method will return FALSE.

Answer : The method will throw an exception.

A session bean's 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.

D. For checked exceptions from which the bean cannot recover, throw an EJBException that

wraps the original exception.


Options are :

  • A,D
  • C,D
  • A,C
  • A,B

Answer : A,D

310-110 Sun Certified Mobile Application Developer for J2ME Set 2

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?



Options are :

  • @ManyToMany(mappedBy="emps") on the projects field, @ManyToMany on the emps field
  • @ManyToMany on the projects field, @ManyToMany(mappedBy="projects") on the emps field
  • @ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany(mappedBy="projects") on the emps field
  • @ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany on the emps field

Answer : @ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany(mappedBy="projects") on the emps field

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 bean's state-management type

E. enterprise bean's remote home interface

F. enterprise bean's local business interface


Options are :

  • A,C
  • E,C
  • A,B
  • A,F

Answer : A,C

Which statement about the combination of mapping defaults, annotations, and XML descriptors is

correct?



Options are :

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

Answer : If multiple entity listeners are defined, the order in which they are invoked can be defined or overwritten in the XML descriptor.

310-110 Sun Certified Mobile Application Developer for J2ME Set 3

A session bean calls the setRollbackOnly method on the EJBContext 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.


Options are :

  • B,E
  • B,D
  • B,A
  • B,C

Answer : B,E

The Java Persistence API defines a notion of propagation of a persistence context. Which

statement is correct?



Options are :

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

Answer : Persistence context propagation avoids the need for the application to pass references of entity manager instances.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions