The actual 1Z0-895 software associated with Ucertify can easily examine the testee whether or not to learn the actual Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam knowledge strongly and also real solutions. The actual Ucertify 1Z0-895 products are contain multiple pick. Candidate can choose different bundle goods for your 1Z0-895 pdf or even 1Z0-895 vce software according to their very own understand of the 1Z0-895 scenario.

2016 Jul 1Z0-895 practice exam

Q11. Given a session bean defines: 

11. @Stateless (name = “MrBean”) 

12. public class source SecureBean implements local business, remoteBusiness { 

Where LocalBusiness is a local business interface and RemoteBusines is a remote business interface. 

The following deployment descriptor entries represent the only security-related metadata: 

Which is true about the security roles of clients MrBean? 

A. Only LocalBusiness clients must be in role A. 

B. Only LocalBusiness clients must be in role B. 

C. Both LocalBusiness and RemoteBusiness Clients must be in role A. 

D. Both LocalBusiness and RemoteBusiness clients must NOT be in role A. 

Answer: C 


Q12. FooBean and BarBean are both EJB 3.x stateless session beans with bean-managed transaction demarcation. The business method foo in FooBean starts a UserTransaction and invokes the business method bar in BrBean. 

Given: 

What is the expected result of this method invocation assuming control reaches Line 12? 

A. FooBean.foo method receives MyAppException. 

B. The container discards the BarBean bean instance. 

C. FooBean.foo method receives a javax.ejb.EJBException that wraps MyAppException. 

D. FooBean.foo method receives javax.transaction.TransactionRolledbackException. 

Answer: D 

Explanation: The transaction will roll back. 

Note: 

* In bean-managed transaction demarcation, the code in the session or message-driven bean explicitly marks the boundaries of the transaction. Although beans with container-managed transactions require less coding, they have one limitation: When a method is executing, it can be associated with either a single transaction or no transaction at all. If this limitation will make coding your bean difficult, you should consider using bean-managed transactions. 

Reference: The Java EE 5 Tutorial, Bean-Managed Transactions  


Q13. Suppose a developer wants to create an automatic persistent timer that performs data validation every hour. Given the following stateless session bean: 

@Stateless 

Public class OrderVerificationBean { 

Private void verificationExternalOrders () { 

/ / do something 

What is the minimum modification you would need to make to the bean to create the automatic persistent timer? 

A. Modify the verifyExternalOrders methos to look like this: @Schedule private void verifyExternalOrders () { / do something } 

B. Modify the verifyExternalOrders method to look like this: 

@Schedule (hour = “*”) 

private void verifyExternalOrders () { 

/ / do something 

C. Modify the verifyExternalOrders method to look like this: 

@Schedule (persistent = true) 

private void verifyExceptionalOrders () { 

/ / do something 

D. Modify the verifyExternalOrders method to look like this: 

@Schedule (hour = “*”, persistent = true) 

private void verifyExceptionalOrders () { 

/ / do something 

Answer: B 

Explanation: 

Not D: Timers are persistent by default. If the server is shut down or crashes, persistent timers are saved and will become active again when the server is restarted. If a persistent timer expires while the server is down, the container will call the @Timeout method when the server is restarted. 

Nonpersistent programmatic timers are created by calling TimerConfig.setPersistent(false) and passing the TimerConfig object to one of the timer-creation methods. 


Q14. A developer writes three interceptor classes: AInt, BInt, and CInt. Each interceptor class defines an AroundInvoke method called interceptor. In the ejb-jar.xml descriptor, CInt is declared as the default interceptor. 

FooBean is a stateless session bean with a local business interface Foo that declares a method Foo (): 

10. @Stateless 

11. @Interceptors(AInt.class) 

12. public class FooBean Implements Foo { 

13. 

14. @Interceptors (BInt.class) 

15. @ExcludeClassInterceptors 

16. public void foo () {} 

17. } 

What is the interceptor order when the business method foo () is invoked? 

A. BInt 

B. CInt, BInt 

C. CInt, AInt, BInt 

D. BInt, AInt, CInt 

Answer: B 

Explanation: The default Intercepter, CInt, comes first. The class intercepter AInt is excluded by @ExcludeClassInterceptors, so the Method Intercepter BInt would be next in order. 

Note 1: By default the ordering of interceptors when invoking a method are 

* External interceptors ** Default interceptors, if present ** Class interceptors, if present ** Method interceptors, if present 

* Bean class interceptor method Note 2: Annotation Type ExcludeClassInterceptors Used to exclude class-level interceptors for a business method or timeout method of a target class. 

Reference: EJB Interceptors 

http://docs.jboss.org/ejb3/app-server/tutorial/interceptor/interceptor.html 


Q15. While excepting a business method in a stateless session bean the container rolls back the method’s transaction. Which three are possible causes for the container’s behavior? (Choose three.) 

A. The bean uses container-managed transactions and invokes EJBContext.setRollbackOnly. 

B. The bean uses container-managed transactions and invokes EJBContext.getRollbackOnly. 

C. The business method throws a java.lang.NullPointerException. 

D. The business method throws a checked exception of a class type that is marked with the @ApplicationException annotation with the rollback element value true. 

E. The business method throws a unchecked exception of a class type that is marked with the @ApplicationException annotation with the rollback element value true. 

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: ADF 

Explanation: A: setRollbackOnly 

Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit. Only enterprise beans with container-managed transactions are allowed to use this method. 

Note: 

* In a stateless session bean with bean-managed transactions, a business method must commit or roll back a transaction before returning. 

* Bean-Managed Transactions In bean-managed transaction demarcation, the code in the session or message-driven bean explicitly marks the boundaries of the transaction. Although beans with container-managed transactions require less coding, they have one limitation: When a method is executing, it can be associated with either a single transaction or no transaction at all. If this limitation will make coding your bean difficult, you should consider using bean-managed transactions. 

* (incorrect) Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time. 

Incorrect: 

B: getRollbackOnly 

Test if the transaction has been marked for rollback only. An enterprise bean instance can use this operation, for example, to test after an exception has been caught, whether it is fruitless to continue computation on behalf of the current transaction. Only enterprise beans with container-managed transactions are allowed to use this method. 


certifyforall.com

Far out 1Z0-895 exam price:

Q16. 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. getEJBObject 

B. sessionCtx.setRollbackOnly 

C. sessionCtx. getMessageContext 

D. sessionCtx. getBusinessObject 

E. sessionCtx. getEJBLocalObject 

Answer: BD


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

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 


Q18. A developer implements a stateless session bean as a timed object. The bean contains two local business methods with the transaction attribute REQUIRED. 

A client begins a UserTransaction and calls the foo local business method. The foo method returns five seconds later. The client rolls back the transaction and then calls the bar local business method. Assuming there have been no other client invocations on the stateless session bean, what is the value of the size variable when control reaches Line 18? 

A. 0 

B. 1 

C. -1 

Answer: A 

Explanation: An enterprise bean usually creates a timer within a transaction. If this transaction is rolled back, the timer creation also is rolled back. 

The transaction will roll back. The creation of the timer will rock back. There will be zero timers. 

Note: The UserTransaction interface defines the methods that allow an application to explicitly manage transaction boundaries. 

rollback() rolls back the transaction associated with the current thread. 

Note 2: size() 

Returns the number of elements in this collection. If this collection contains more than 

Integer.MAX_VALUE elements, returns Integer.MAX_VALUE. 

Reference: The Java EE 6Tutorial. PartNo: 821– Transactions andTimers 


Q19. 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: 

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

checkGooods, getUniqueId, checkAmount, storeTranfer 

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

A. 0.addTransferREQUIRED 

1.checkGoodsREQUIRED 

2.getUnigueIdREQUIRES_NEW 

3.checkAmountsNOT_SUPPORTED 

4.storeTransferMANDATORY 

B. 0.addTransferREQUIRED 

1.checkGoodsREQUIRED 

2.getUnigueIdREQUIRED 

3.checkAmountsREQUIRED 

4.storeTransferREQUIRED 

C. 0.addTransferREQUIRED 

1.checkGoodsREQUIRED 

2.getUnigueIdREQUIRES_NEW 

3.checkAmountsNEVER 

4.storeTransferMANDATORY 

D. 0.addTransferNOT_SUPPORTED 

1.checkGoodsREQUIRED 

2.getUnigueIdREQUIRES_NEW 

3.checkAmountsNOT_SUPPORTED 

4.storeTransferMANDATORY 

Answer: A 

Explanation: 

Step 2: Must start a new transaction. use REQUIRES_NEW 

Step 3: No need for this step: use Not Supported 

Use the.NotSupported.attribute for methods that don’t need transactions. Because transactions involve overhead, this attribute may improve performance. 

Step 4: Use Mandatory: 

Use the Mandatory attribute if the enterprise bean’s method must use the transaction of the client. 

Note: 

* In an enterprise bean with container-managed transaction (CMT) demarcation, the EJB container sets the boundaries of the transactions. You can use container-managed transactions with any type of enterprise bean: session, or message-driven. Container-managed transactions simplify development because the enterprise bean code does not explicitly mark the transaction’s boundaries. The code does not include statements that begin and end the transaction. 

* A transaction attribute can have one of the following values: 

Required RequiresNew Mandatory NotSupported Supports Never 

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

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

* Mandatory 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 throws the TransactionRequiredException. 

Use the Mandatory attribute if the enterprise bean’s method must use the transaction of the client. 

* NotSupported Attribute If the client is running within a transaction and invokes the enterprise bean’s method, the container suspends the client’s transaction before invoking the method. After the method has completed, the container resumes the client’s transaction. 

If the client is not associated with a transaction, the container does not start a new transaction before running the method. 

Use the NotSupported attribute for methods that don’t need transactions. Because transactions involve overhead, this attribute may improve performance. 

Reference: The Java EE 5 Tutorial, Container-Managed Transactions 


Q20. A developer writes a stateless session bean HelloBean that exposes a local business interface Hello: 

The developer wants to test HelloBean using the EJB 3.1 Embeddable API. Given a main method with the following code: 

100. EJBContainer container = EJBContainer.createEJBContainer(); 

Assuming HelloBean is packaged in hello.jar and included in the classpath, which code correctly acquires a reference to HelloBean? 

A. InitialContext ic = new InitialContext(); 

Hello h = (Hello) ic.lookup(“java:global/hello/HelloBean”); 

B. InitialContext ic = new InitialContext(); 

Hello h = (Hello) ic.lookup(“com.acme.Hello”); 

C. Context c = container.getContext(); 

Hello h = (Hello) ic.lookup(“com.acme.Hello”); 

D. Context c = container.getContext(); 

Hello h = (Hello) ic.lookup(“java:global/hello/HelloBean”); 

Answer: B 

Explanation: You can initialize the InitialContext class to obtain a context, that can further be used to perform the lookup.