The Renovate Guide To 1Z0-895 vce

Want to know Examcollection 1Z0-895 Exam practice test features? Want to lear more about Oracle Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam certification experience? Study Approved Oracle 1Z0-895 answers to Far out 1Z0-895 questions at Examcollection. Gat a success with an absolute guarantee to pass Oracle 1Z0-895 (Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam) test on your first attempt.


2020 Oracle Official New Released 1Z0-895 ♥♥
https://www.certifytools.com/1Z0-895-exam.html


Q1. You are writing a client that sends a message to a JMS queue. The client includes the following code snippet: 

A. The message can be consumed by durable subscriber. 

B. In the first line, the argument to the createProducer method needs to be cast to a Destination. 

C. The message is sent using non-default deliver mode, priority, and expiration time values. 

D. You could add more name-value pairs to the message body of the MapMessage if they were required by your application. 

Answer:

Explanation: createMapMessage 

MapMessage createMapMessage() throws JMSException Creates a MapMessage object. A MapMessage object is used to send a self-defining set of name-value pairs, where names are String objects and values are primitive values in the Java programming language. 

Reference: javax.jms, Interface Session 

Q2. A developer is writing client code to access a session bean deployed to a server instance. 

The client can access the session bean under which of these circumstances? (Choose three) 

A. The client is deployed in the same JVM as the session bean and the session bean has a local interface. 

B. The client is deployed in the same JVM as the session bean and the session bean exposes a no-interface view. 

C. The client is deployed in a different JVM from the session bean and the session bean has a local interface. 

D. The client is deployed in a different JVM from the session bean and the session bean has a remote interface. 

E. The client is deployed in a different JVM from the session bean and the session bean has a no-interface implementation. 

Answer: ABD 

Explanation: D: If your architecture has a requirement whereby the client application (web application or rich client) has to run on a different JavaVirtual Machine (JVM) from the one that is used to run the session beans in an EJB container, then you need to use the remote interface. 

Q3. Suppose an EJB component is named HelloWorldBean is deployed as a standalone ejb-jar. Assuming the HelloWorldBean is implemented as follows: 

Which types of clients are guaranteed to have access to HelloWorldBean: 

A. Java EE application client container applications 

B. Java EE ejb components within the same ejb-jar 

C. Java EE web-tier component applications deployed in the same container 

D. Java EE ejb component applications deployed in the same container 

Answer:

Q4. How many interceptor classes can be applied to a single stateful session bean? 

A. a maximum of one 

B. any number may be applied 

C. one for each business method 

D. one for each business interface 

Answer:

Explanation: The @Interceptors annotation can take an array of classes, so you can bind more than one class-level interceptor this way, e.g. 

@Stateless @Interceptors ({TracingInterceptor.class, SomeInterceptor.class}) public class EmailSystemBean { 

Reference: EJB Interceptors 

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

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

Q6. A developer writes a stateful session bean FooBean with two local business interfaces Foo and bar. The developer wants to write a business method called getBar for interface Foo that returns a Bar reference to the same session bean identity on which the client onvokes getBar. 

Which code, when inserted on line 12 below implements the getBar method with the wanted behavior? 

10. @Resource SessionContext sessionCtx; 

11. public Bar getbar () { 

12. 

13. } 

A. Return (bar) this; 

B. Return (bar) new FooBarBean(); 

C. Return (bar) sessionCtx.lookup(“FooBarBean”) 

D. Return (bar) sessionCtx.getBusinessObject(Bar.class); 

E. Return (bar) session Ctx.lookup(“java: comp/env/ejb/FooBarBean”); 

Answer:

Q7. Given the following stateless session bean implementation classes: 

Assuming no other transaction-related metadata, what are the transaction attributes of methodA, methodB, and methodC respectively? 

A. MANDATORY, MANDATORY , and MANDATORY 

B. REQUIRED, MANDATORY, and REQUIRES_NEW 

C. MANDATORY, MANDATORY , and REQUIRES_NEW 

D. REQUIRED, REQUIRES_NEW, and REQUIRES_NEW 

Answer:

Explanation: 

Note: 

* You can only bring out the effects of transaction attributes only when you call the method through a session bean instance and NOT through a direct method call. Even if your methods are within the same bean, you need to get the local instance of the same bean and call through its local interface instead of a direct method invoke. 

* The enum TransactionAttributeType is used with the TransactionAttribute annotation to specify whether the methods of a session bean or message driven bean are called with a valid transaction context. 

* MANDATORY If a client invokes the enterprise bean's method while the client is associated with a transaction context, the container invokes the enterprise bean's method in the client's transaction context. 

* REQUIRES_NEW The container must invoke an enterprise bean method whose transaction attribute is set to REQUIRES_NEW with a new transaction context. 

Reference: TransactionAttributeType.MANDATORY 

Q8. Assume an EJB application is comprised of the following EJB fragment: 

You have been asked to convert the type of InventoryReportBean into a singleton session bean. How would you achieve this task? 

Exhibit C: 

Exhibit D: 

A. Keep InventoryReportBean as it is, modifying the internal structure to function as a singleton 

B. Change the @Stateless annotation of InventoryReportBean to @Singleton 

C. Create an ejb-jar.xml file, and override the annotation configuration information as in exhibit C above. 

D. Create an ejb-jar.xml file, and override the annotation configuration information as in exhibit D above. 

Answer:

Explanation: Note the line with <override-type> 

Q9. Given code snippets from two files: 

Which four code changes, when used together, create a valid JMS message-driven bean? (Choose four) 

A. Make class MessageDog public 

B. Make the MessageDog constructor no-arg 

C. Make the MessageDog constructor public 

D. Move the onMessage method to class MessageDog. 

E. Change MessageDog so that it is NOT a subclass of Dog. 

F. Make class MessageDog implement MessageListner instead of MessageDrivenBean. 

Answer: ABCF 

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

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