1Z0-860 - Java Enterprise Edition 5 Business Component Developer Certified Professional Exam

Go back to Oracle

Example Questions

Within a Java EE environment, which annotation can be used to inject an entity manager factory? 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? A Java 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 EJB role responsibilities? (Choose two.) Consider the following classes: 11.©Entity Auction { 12. @ld int id; 13. @OneToOne Item item; 14.} 11.©Entity Itemj 12. @ld 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? 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? 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? An enterprise developer needs to modify the order of interceptor method execution specified by the Bean Provider, but does NOT have access to the bean's source code. No deployment descriptor was provided in the ejb-jar delivered by the Bean Provider. Which represents the solution to this problem? Which two are restrictions of beans with bean-managed transactions? (Choose two.) A Java Persistence application uses entities mapped to tables from two datasources in the same transaction. What statement is correct? 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.) Given: 10.©Stateless 11. @RunAs("X") 12. public class SecureBeanOl implements SecureOl { 13. @EJB Secure02 secure02; 23. @RolesAllowed("A") 24. public void methodA0 { 25. secureO2.methodB0; 26.} 10.©Stateless 11. public void SecureBean02 implements Secure02{ 23. @RolesAllowed("A") 24. public void methodB0 { A user who is only in role A invokes SecureOl. methodA. Assuming NO other security-related metadata, what is the expected result? A business method of a stateless session bean with a transaction attribute REQUIRED executes a Java 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 developer has created an application-managed entity manager. Which statement is correct? A developer writes a stateless session bean with a constructor, a PostConstruct method, a PreDestroy method, and this business method: 11. public String helloQj 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? 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.) The Java Persistence API defines the Query interface. Which two statements about the Query.executeUpdate method are true? (Choose two.) The Java Persistence API defines a notion of propagation of a persistence context. Which statement is correct? Which two statements are true about EJB 3.0 JMS message-driven beans? (Choose two.) 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 Java Persistence application wants to use optimistic locking. Which statement that describes the functionality of optimistic locking is correct? 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, readeM has booka and bookb, while reader2 has bookc and bookd. Which query returns a Collection of fewer than four elements? Which must result in the destruction of a stateful session bean? A developer's objective is to end the persistence context associated with an application-managed entity manager. Which statement is correct? 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 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 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 developer writes client code that runs in a Java EE container and accesses an EJB 3.0 stateful session bean. Which three statements are correct? (Choose three.) Which statement about entity manager is true? A session bean's business method invokes UserTransaction.setRollbackOnly and receives an HlegalStateException. Under which circumstance canthis happen? 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-link> <injection-target> <injection-target-class>acme.FooBean</injection-target-class> <injection-target-name>bar</injection-target-name> </injection-target> </ej b-1 o c a I- ref> Which environment annotation, when declared within the FooBean bean class, is equivalent to the ejb- local-ref shown above? Consider a deep inheritance hierarchy consisting of Java Persistence entity classes, non-entities, and mapped superclasses. Which statement is correct, assuming NO mapping descriptor is present? Given: 5. public interface MrB1 { 6. public interface MrB2 { Ajava 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 developer wants to create a Java 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 query's WHERE clause is correct? 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.) Your application uses the Java 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 business method of a stateless session bean with a transaction attribute REQUIRED executes a Java 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.) EJB 3.0 containers must provide a specific subset of which two APIs? (Choose two. FooBean and BarBean are both EJB 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 bar0{ 12. throw new EJBException("unexpected error..."); 13.} Which statement is true about the result of this method invocation assuming execution reaches Line 12? Which statement about mapping using the Java Persistence API is correct? Which statement is correct about a Java EE client of a message-driven bean? A developer writes an interceptor class called Foolnterceptor 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 developer creates a stateless session bean, EmployeeServiceBean, and its interface, EmployeeSeivice. 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 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 EJB-tier. 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 developer writes a stateful session bean with local business interface Bar containing method test. Method test is implemented as 11. ©Remove 12. public void testfj {} A business method in a stateless session bean invokes a reference to bean Bar as follows : 11. @EJB Bar bar; 12. 13. public void foo0 { 14. bar.testfj; 15. bar.testO; 16.} Assuming execution reaches Line 15, what is the expected result? A developer wants to create a portable EJB 3.0 application that includes the following class definition for the Entity Account: 11.©Entity 12. @Entityl_isteners(com. acme.AlertMonitor. class) 13. public class Account { 14. // more code here 15. @PrePersist 16. protected void validateCreate0 {/* more code here */} 17.} Which statement is correct? 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 EJB 3.0 an appropriate solution? (Choose two.) According to the Java 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? The deployment descriptor for a stateless session bean that uses the isCallerlnRole method reads as follows: 3. <security-role-ref> 4. <role-name>manager</role-name> 5. <role-link>humanresources</role-link> 6. <security-role-ref> 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.) 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.) 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?