The examinees who study the Exambible Oracle 1Z0-895 places are success regarding highly certified professors, residing an excellent existence. Exambible has been devoted to build your potential safe and commence your Oracle 1Z0-895 Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam test products through the most recent up-to-date Exambible assessments 1Z0-895 check engine. The desires can come correct simply by commence your 1Z0-895 vce regarding Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam test by means of Exambible Oracle research instructions only. You wont able to stand out your abilities inside the very first endeavor regarding 1Z0-895 check if you are using a other pathway than Oracle. Oracle Oracle 1Z0-895 pdf file will give you brilliance therefore making you sufficient positive about all of your existence.

2021 Jun 1Z0-895 free question

Q51. Which two statements are correct about stateless session beans? (Choose two.) 

A. The bean class may declare instance variables. 

B. The lifetime of the bean instance is controlled by the client. 

C. The container may use the same bean instance to handle multiple business method invocations at the same time. 

D. The container may use the same bean instance to handle business method invocations requested by different clients, but not concurrently. 

Answer: AC 

Explanation: * A: Stateless session beans are EJB's version of the traditional transaction processing applications, which are executed using a procedure call. The procedure executes from beginning to end and then returns the result. Once the procedure is done, nothing about the data that was manipulated or the details of the request are remembered. There is no state. 

These restrictions don't mean that a stateless session bean can't have instance variables and therefore some kind of internal state. There's nothing that prevents you from keeping a variable that tracks the number of times a bean has been called or that tracks data for debugging. An instance variable can even hold a reference to a live resource like a URL connection for writing debugging data, verifying credit cards, or anything else that might be useful. 

C: A stateless session bean is relatively easy to develop and also very efficient. Stateless session beans require few server resources because they are neither persistent nor dedicated to one client. Because they aren't dedicated to one client, many EJB objects can use just a few instances of a stateless bean. A stateless session bean does not maintain.conversational state relative to the EJB object it is servicing, so it can be swapped freely between EJB objects. As soon as a stateless instance services a method invocation, it can be swapped to another EJB object immediately. Because there is no conversational state, a stateless session bean doesn't require passivation or activation, further reducing the overhead of swapping. In short, they are lightweight and fast! 

* The Lifecycle of a Stateless Session Bean Because a stateless session bean is never passivated, its lifecycle has only two stages: nonexistent and ready for the invocation of business methods. The EJB container typically creates and maintains a pool of stateless session beans, beginning the stateless session bean’s lifecycle. The container performs any dependency injection and then invokes the method annotated @PostConstruct, if it exists. The bean is now ready to have its business methods invoked by a client. 

At the end of the lifecycle, the EJB container calls the method annotated @PreDestroy, if it exists (not B). The bean’s instance is then ready for garbage collection. 


Q52. A developer writes a Singleton bean that holds state for a single coordinate: An update thread acquires an EJB reference to CoordinateBean and alternates between invoking SetCoordinate (0, 0) and SetCoordinate (1, 1) in a loop. 

At the same time, ten reader threads each acquire an EJB reference to CoordinateBean and invoke getCoordinate () in a loop. 

Which represents the set of all possible coordinate values [X, Y] returned to the reader threads? 

A. [0, 0] 

B. [1, 1] 

C. [0, 0], [1, 1] 

D. [0, 0], [0, 1], [1, 0], [1, 1] 

Answer: C 


Q53. Given the following stateful bean: 

10. @Stateful 

11. @TransactionAttribute(TransactionAttributeType.SUPPORTS) 

12. public class VideoBean implements video { 

13. / / insert code here 

14. public void method () {} 

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.CONTAINER) 

C. @TransactionAttribute(transactionAttributeType.MANDATORY) 

D. @transactionAttribute(TransactionattributeType.RECQUIRES_NEW) 

Answer: C 


Q54. Given the following stateless session bean: How would you change the EJB to prevent multiple clients from simultaneously accessing the sayHello method of a single bean instance? 

A. Convert sayHello into a synchronized method 

B. Execute the call to generateLocalizedHello in a synchronized block 

C. Convert generateLocalizehello into a synchronized method 

D. Convert HelloWordBean into a singleton bean 

E. No changes are needed 

Answer: A 

Explanation: * It is not possible for two invocations of synchronized methods on the same object to interleave. When one thread is executing a synchronized method for an object, all other threads that invoke synchronized methods for the same object block (suspend execution) until the first thread is done with the object. 

* When a synchronized method exits, it automatically establishes a happens-before relationship with any subsequent invocation of a synchronized method for the same object. This guarantees that changes to the state of the object are visible to all threads. 

Reference: The Java Tutorial, Synchronized Methods 


Q55. You have been tasked to build a jar file that can be used by a Java SE client to access the remote instance of the OrderProcessingBean. Given the following design: 

Which classes would need to be included in the client jar file? 

A. B, Order 

B. A, Order 

C. A, B, Order 

D. A, B, Order, OrderProcessingBean 

Answer: B 

Explanation: 

Note: 

* An EJB client JAR file is an optional JAR file that can contain all the class files that a client program needs to use the client view of the enterprise beans that are contained in the EJB JAR file. 

* If all your EJBs are in the same EAR then you can use local interfaces, if not you need remote interfaces. 


1Z0-895  free question

Improved 1Z0-895 exam question:

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


Q57. Which three methods can Bean Developer use in any EJB compliant container implementing the full Java EE6 product? (Choose three.) 

A. Class.getClassLoader 

B. FileInputStream.read 

C. DataSource.getConnection 

D. EJBContext.getCallerPrincipal 

E. Executors.newSingleThreadExecutor 

F. QueueConnection.createQueueSession 

Answer: BCD 

Explanation: D: Use EJBContext. getCallerPrincipal() to obtain the java.security.Principal that identifies the caller. 

Incorrect: 

A: Do not load native libraries. 

E: Not allowed: Starting, stopping, or managing threads in any way. That restriction eliminates the possibility of conflicts with the EJB container's responsibilities of managing locking, threading, and concurrency issues. 

Reference: Programming restrictions on EJB 

Reference: javax.ejb Interface EJBContext 


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


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


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

11. public class MyData implements java.io.Serialization { 

12. int a; 

13. } 

Methods foo is implemented with 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 foo with the following code: 

11. MyData data = new MyData(); 

12. data.a = 1; 

13. Fooref.foo(data); 

14. System.out.printIn(data.a); 

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

A. 0 

B. 1 

C. 2 

Answer: B