Cause all that matters here is passing the Oracle 1Z0-895 exam. Cause all that you need is a high score of 1Z0-895 Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam exam. The only one thing you need to do is downloading Testking 1Z0-895 exam study guides now. We will not let you down with our money-back guarantee.
♥♥ 2021 NEW RECOMMEND ♥♥
Free VCE & PDF File for Oracle 1Z0-895 Real Exam (Full Version!)
★ Pass on Your First TRY ★ 100% Money Back Guarantee ★ Realistic Practice Exam Questions
Free Instant Download NEW 1Z0-895 Exam Dumps (PDF & VCE):
Available on:
http://www.surepassexam.com/1Z0-895-exam-dumps.html
Q11. A developer implements a CMT session bean with a method storeBoth which inserts data both a related database and an LDAP server. The relational database supports transactions while the LDAP system does NOT.
Given that both updates should succeed or be rolled back, while is the best solution?
A. Implement the SessionSynchoronization interface in the session bean. In the afterCompleteion method, the LDAP inserts are rolled back if false is passed as an argument to the afterCompletion method.
B. Define the transaction attribute of the method storeBoth as REQUIRED. The container manages the transactions and will roll back modifications if something goes wrong in either database insert or LDAP insert.
C. Define the transaction attribute of the method storeBoth as REQUIRED_NEW. Carry out the database insert first. Subsequently, execute the LDAP inserts, catching LDAP exceptions. If exceptions are raised, call the SessionContext.setRollBackOnly method.
D. Define the transaction attribute of the method storeBoth as REQUIRED_NEW. Carry out the LDAP insert first. If SessionContext.getRollBackOnly returns false, execute the database inserts, catching SQL exceptions. If exceptions are raised, call the SessionContext.setRollBackOnly.
Answer: C
Explanation: The method should start a new transaction, so we use the REQUIRED_NEW attribute.
For the LDAP operation we can only detect LDAP exceptions. We cannot check the status of the LDAP operation through SessionContext.getRollBackOnly.
Note:
* CMT - Container-Managed Transactions
* RequiresNew Attribute If the client is running within a transaction and invokes the enterprise bean’s method, the container takes the following steps:
Suspends the client’s transaction
Starts a new transaction
Delegates the call to the method
Resumes the client’s transaction after the method completes
If the client is not associated with a transaction, the container starts a new transaction before running the method.
You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction. Reference: The Java EE 5 Tutorial, Container-Managed Transactions
Q12. 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: BCD
Q13. Given the following code in an EJB session bean:
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:cmp/env/jdbc/employeeDB);
Answer: E
Q14. Which is true about caller security principal propagation for asynchronous EJB method Invocations?
A. Caller security principal propagates along with an asynchronous EJB method invocation.
B. Caller security principal does not propagate along with an asynchronous EJB method invocation.
C. Caller security principal propagates along with an asynchronous EJB method invocation only if the target bean has at least one protected method.
D. Caller security principal propagates along with an asynchronous EJB method invocation only if the calling bean has at least one protected method.
Answer: D
Explanation: One important caveat of asynchronous method invocation is that transactions are not propagated to the asynchronous method—a new transaction will be started for the asynchronous method. However, unlike transactions, the security principal will be propagated.
Declarative security is based only on the principal and the method being invoked, whereas programmatic security can take state into consideration.
Q15. MyMsgBean is a JMS message-driven with container-managed transaction demarcation. FooBean is an EJB 3.x stateless session bean that sends messages to the JMS destination with which MyMsgBean is associated.
MyMsgBean’s message listener method has transaction attribute REQUIRED, and is defined as follows:
Which statement is true about the result of the message processing?
A. FooBean receives javax.ejb.EJBException.
B. The container discards the MyMsgBean bean instance.
C. FooBean receives the original RuntimeException thrown from the message listener method.
D. The container does NOT roll back the transaction, and FooBean can continue the transaction.
Answer: B
Explanation:
Note:
* Required Attribute If the client is running within a transaction and invokes the enterprise bean’s method, the method executes within the client’s transaction. If the client is not associated with a transaction, the container starts a new transaction before running the method.
The Required attribute is the implicit transaction attribute for all enterprise bean methods running with container-managed transaction demarcation. You typically do not set the Required attribute unless you need to override another transaction attribute. Because transaction attributes are declarative, you can easily change them later.
Q16. Given an JMS 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 except java.rmi.RemoteException.
D. Its message listener method can throw any checked exception that implements java.io.Serializable.
Answer: A
Q17. A stateful session bean needs to restore its conversational state to its initial state if the transaction in which the bean is participating rolls back.
Which bean method can be used to do this?
A. SessionContext.setRollbackOnly
B. SessionContext.getUserTransaction
C. SessionSynchronization.afterCompletion
D. SessionSynchrinization.beforeCompletion
Answer: C
Explanation: The afterCompletion method notifies a stateful session bean instance that a transaction commit protocol has completed, and tells the instance whether the transaction has been committed or rolled back.
Returns:
True if the current transaction is marked for rollback, false otherwise.
Reference: javax.ejb, Interface SessionSynchronization
Q18. A stateful session bean contains a number of instance variables. The types of instance variables A and B are 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 of instance variable B in a @postcreate annotated method.
C. The value of helper variable C is used to create the value of instance variable B in 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: CE
Q19. 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 life time of the bean and that the information to connect to the remote system is defined in JNDI.
Which statement describes how to manage the data correctly?
A. Read the data in the bean's constructor.
B. The data can only be read in the bean's 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
Q20. Given this code snippet from a JMS message driven bean class X:
When this bean class handles a message, which is correct?
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 12.
D. After a message delivery an exception is thrown.
E. After a message delivery the result is unpredictable.
F. This is NOT a compliant JMS message-driven bean.
Answer: F