All About Realistic 1Z0-895 pdf

Testking 1Z0-895 Questions are updated and all 1Z0-895 answers are verified by experts. Once you have completely prepared with our 1Z0-895 exam prep kits you will be ready for the real 1Z0-895 exam without a problem. We have Up to date Oracle 1Z0-895 dumps study guide. PASSED 1Z0-895 First attempt! Here What I Did.


2024 Oracle Official New Released 1Z0-895 ♥♥
https://www.certleader.com/1Z0-895-dumps.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 bean developer wants to write a stateless session bean class that implements the following remote business interface: 

@Remote 

Public interface Foo { 

Void bar () throws Exception; 

Which bean class method is valid? 

A. @Asynchronous 

public void bar () throws Exception { . . . } 

B. @Asynchronous 

Future <void> bar () { . . .} 

C. void bar () throws Exception { . . . } 

D. public void bar () { . . . } 

Answer:

Explanation: with EJB 3.1, you can use a simple session EJB with the @Asynchronous annotation on the method which must be called asynchronously. 

@Stateless 

@Remote(HelloEjbAsynchronousRemote.class) 

public class HelloEjbAsynchronous implements HelloEjbAsynchronousRemote { 

@Asynchronous 

@Override 

public Future<String> ejbAsynchronousSayHello(String name){ 

If your method has a return value, your method has to return an AsyncResult object which is an implementation of Future. 

Q3. A Java EE application server has four different security realms for user management. One of the security realms is custom made. This realm supports only individual user entries, no grouping of users, and is used by the application. Which two statements are true? (Choose two.) 

A. EJB developers cannot use the isCallerInRole method. 

B. The annotation @RunAs(“AAA”) can still be used for this application. 

C. All security roles need a role-link entry in the deployment descriptor. 

D. All security roles can be mapped successfully to individual users in the realm. 

Answer: BD 

Explanation: 

Not A, not C: A.security role reference.defines a mapping between the name of a role that is called from a web component using.isUserInRole(String role).and the name of a security role that has been defined for the application. If no.security-role-ref.element is declared in a deployment descriptor and the.isUserInRole.method is called, the container defaults to checking the provided role name against the list of all security roles defined for the web application. Using the default method instead of using the.security-role-ref.element limits your flexibility to change role names in an application without also recompiling the servlet making the call. 

For example, to map the security role reference cust to the security role with role name bankCustomer, the syntax would be: 

<servlet> 

<security-role-ref> <role-name>cust</role-name> <role-link>bankCustomer</role-link> </security-role-ref> 

</servlet> 

Note: 

* A realm is a security policy domain defined for a web or application server. A realm contains a collection of users, who may or may not be assigned to a group. 

* The protected resources on a server can be partitioned into a set of protection spaces, each with its own authentication scheme and/or authorization database containing a collection of users and groups. A realm is a complete database of users and groups identified as valid users of one or more applications and controlled by the same authentication policy. 

* In some applications, authorized users are assigned to roles. In this situation, the role assigned to the user in the application must be mapped to a principal or group defined on the application server. 

* A role is an abstract name for the permission to access a particular set of resources in an application. A role can be compared to a key that can open a lock. Many people might have a copy of the key. The lock doesn’t care who you are, only that you have the right key. 

Reference: The Java EE 6 Tutorial, Declaring and Linking Role References 

Q4. A developer implements a session bean which acts as a session facade for an application. This means that clients will only see this session bean's interface which offers the application interface, where are three distinct roles known at development time: "user", "admin", and "guest". The majority of the methods will be used by role "user". All methods must have role permissions active and roles may be added or changed in the future. 

Which two scenarios are correct? (Choose two.) 

A. The developer annotates the bean class with @PermitAll and annotates the methods used by role "guest" or "admin" individually. 

B. The developer annotates the bean class with @DenyAll and annotates the methods used by role "user", "guest", or "admin" individually. 

C. The developer defines individual method permissions for the methods used by roles "user "guest", and "admin" In the deployment descriptor. 

D. The developer annotates the bean class with @RolesAllowed("user") and annotates the methods used by role "guest" or "admin" individually. 

E. The developer defines a method permission with method name "*" and role "user" and adds individual method permissions for the methods used by roles "guest" and "admin" in the deployment descriptor. 

Answer: DE 

Q5. Which two are true about the client view of a message-driven bean? (Choose two.) 

A. References to message destinations can be infected. 

B. References to message destinations cannot be looked up in the client's JNDI namespace. 

C. Clients of a message destination need to know that the destination is listened to by a pool of message consumers, 

D. Clients of a message destination do NOT need to know that the destination is listened to by a message-driven bean. 

Answer: BC 

Explanation: Client components do not locate message-driven beans and invoke methods directly on them. Instead, a client accesses a message-driven bean through, for example, JMS by sending messages to the message destination for which the message-driven bean class is the MessageListener. 

Reference: The Java EE 6 Tutorial, What is a Message-Driven Bean? 

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

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. 

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

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 

Q8. Assume you would like to receive notification from the container as a stateless session bean transitions to and from the ready state. 

Which of the following life cycle back annotations would you use? (Choose one.) 

A. @PostConstruct, @PostDestroy 

B. @PostConstruct, @PreDestroy 

C. @PreConstruct, @PostDestroy 

D. @PostConstruct, @PostDestroy, @Remove 

E. @PostConstruct, @PreDestroy, @Remove 

Answer:

Explanation: The Lifecycle of a Stateless Session Bean 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. The bean’s instance is then ready for garbage collection. 

Lifecycle of a Stateless Session Bean: 

Note: An enterprise bean goes through various stages during its lifetime, or lifecycle. Each type of enterprise bean (stateful session, stateless session, singleton session, or message-driven) has a different lifecycle. 

Reference: http://docs.oracle.com/javaee/6/tutorial/doc/giplj.html 

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

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