After you obtain the Pass4sure 1Z0-895 product or service, we can supply absolutely free upgrade in time first season. Level of quality together with Value for your 1Z0-895 Test, 100% Assure to feed Ones 1Z0-895 Test, Down loadable, Entertaining 1Z0-895 Assessment applications, Verified Responses Investigated by means of Skilled professionals, Exhaust together with Lower queries while experienced in this Checks, 1Z0-895, Apply Examination Inquiries combined with exhibits. Some of our 1Z0-895 Apply Examination Inquiries are financed by means of the 100% Guarantee.

2016 Aug 1Z0-895 test engine

Q31. Which is a correct way to define a runtime exception as an EJB 3.x application exception? 

A. public class MyAppException extends javax.ejb.EJBException 

B. @ApplicationException public class MyAppException extends javax.ejb.EJBException 

C. public class MyAppException extends javax.lang.EJBException 

D. @ApplicationException public class MyAppException extends javax.lang.EJBException 

Answer: B 

Explanation: Use the @javax.ejb.ApplicationException annotation to specify that an exception class is an application exception thrown by a business method of the EJB. The EJB container reports the exception directly to the client in the event of the application error. 

Note: java.lang.Object java.lang.Throwable java.lang.Exception 

java.lang.RuntimeException 

javax.ejb.EJBException 

javax.ejb.

public class EJBException 

extends java.lang.RuntimeException 

The EJBException is thrown to report that the invoked business method or callback method could not be completed because of an unexpected error (e.g. the instance failed to open a database connection). 

Example: 

The following.ProcessingException.java.file shows how to use the.@ApplicationException.annotation to specify that an exception class is an application exception thrown by one of the business methods of the EJB: 

package examples; 

import javax.ejb.ApplicationException; 

/** * Application exception class thrown when there was a processing error * with a business method of the EJB. Annotated with the * @ApplicationException annotation. */ @ApplicationException()public class ProcessingException extends Exception { 

Reference: Programming WebLogic Enterprise JavaBeans, Version 3.0 programming Application Exceptions 


Q32. A developer writes a stateless session bean FooBean and uses its deployment descriptor to declare a local ejb dependency on a stateful session bean in the same ejb-jar. 

Which environment annotation, when declared within the FooBean bean class, is equivalent to the ejb-local-ref shown above? 

A. @EJB(beanName=“BarBean”) Private acme.Bar barRef; 

B. @EJB(name=“bar”, beanName=“BarBean”) Private acme.Bar barRef; 

C. @EJB(name=“barRef”, beanName=“BarBean”) Private acme.Bar bar; 

D. @EJB(name=“ejab/barRef”, beanName=“BarBean”) Private acme.Bar bar; 

Answer: C 

Explanation: name is barRef 

Example: 

ejb-local-ref share [gp].share [fb].share [tw].contribute Via annotation Usable by EJB, Interceptor, Servlet, Filter, or Listener package org.superbiz.refs; 

import javax.ejb.EJB; 

import javax.ejb.Stateless; 

import javax.naming.InitialContext; 

@Stateless 

@EJB(name = "myFooEjb", beanInterface = FooLocal.class) 

public class MyEjbLocalRefBean implements MyBeanInterface { 

@EJB 

private BarLocal myBarEjb; 

public void someBusinessMethod() throws Exception { 

if (myBarEjb == null) throw new NullPointerException("myBarEjb not injected"); 

// Both can be looked up from JNDI as well 

InitialContext context = new InitialContext(); 

FooLocal fooLocal = (FooLocal) context.lookup("java:comp/env/myFooEjb"); 

BarLocal barLocal = (BarLocal) 

context.lookup("java:comp/env/org.superbiz.refs.MyEjbLocalRefBean/myBarEjb"); 

Via xml 

The above @EJB annotation usage is 100% equivalent to the following xml. 

<ejb-local-ref> 

<ejb-ref-name>myFooEjb</ejb-ref-name> 

<local>org.superbiz.refs.FooLocal</local> 

</ejb-local-ref> 

<ejb-local-ref> 

<ejb-ref-name>org.superbiz.refs.MyEjbLocalRefBean/myBarEjb</ejb-ref-name> 

<local>org.superbiz.refs.BarLocal</local> 

<injection-target> 

<injection-target-class>org.superbiz.refs.MyEjbLocalRefBean</injection-target-class> 

<injection-target-name>myBarEjb</injection-target-name> 

</injection-target> 

</ejb-local-ref> 


Q33. A java EE application contains a session bean which uses a security role USER. A group called people is defined an LDAP server. Which two define appropriate EJB role responsibilities? (Choose two.) 

A. The deployer defines and configures the LDAP realm. 

B. The system administrator defines and configures the LDAP realm. 

C. The deployer maps the application role USER to the LDAP group people. 

D. The system administrator maps the application role USER to the LDAP group people. 

Answer: BC 


Q34. An enterprise developer has received ejb-jars from multiple Bean Provides and wants to combine them into a single ejb-jar as well as altering the method permissions on some of the beans without recompiling any of the code contained in the ejb-jar. Which is correct? 

A. Bean Provide is the only role that can perform this task. 

B. Deployed is the most appropriate role to perform this task. 

C. Either a Deployer or System Administrator role many perform this task. 

D. This problem cannot be solved using an EJB 3.x-compliant approach. 

E. Application Assembler is the most appropriate role to perform this task. 

Answer: E 

Explanation: Application Assembler 

The Application Assembler combines enterprise beans into larger deployable application units. The input to the Application Assembler is one or more ejb-jar files produced by the Bean Provider(s). The Application Assembler outputs one or more ejb-jar files that contain the enterprise beans along with their application assembly instructions. 

Note: 

* EJB Structure 

The EJB Java ARchive (JAR) file is the standard format for assembling enterprise beans. This file contains the bean classes (home, remote, local, and implementation), all the utility classes, and the deployment descriptors (ejb-jar.xml and sun-ejb-jar.xml). 

* The Application Assembler can also combine enterprise beans with other types of application components when composing an application. 

Reference: Match the seven EJB roles with the corresponding description of the role's responsibilities. 


Q35. 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: D 

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 


certifyforall.com

Up to the minute 1Z0-895 test:

Q36. Which two are programming restrictions in the EJB specification? (Choose two.) 

A. An enterprise bean must NOT attempt to load a native library. 

B. An enterprise bean must NOT declare static fields as final. 

C. An enterprise bean must NOT attempt to create a new security manager. 

D. An enterprise bean must NOT propagate a RuntimeException to the container. 

E. An enterprise bean must NOT attempt to obtain a javax.naming.InitialContext. 

Answer: AC 

Explanation: The following is a list of Java features that you should avoid, hence restricting their use in your EJB components' implementation code: 

(A) Loading native libraries. 

(C) Attempting to create or obtain a class loader, set or create a new security manager (C), stop the JVM, change the input, output, and error streams. That restriction enforces security and maintains the EJB container's ability to manage the runtime environment. 

(not B) Using static, nonfinal fields. Declaring all static fields in the EJB component as final is recommended. That ensures consistent runtime semantics so that EJB containers have the flexibility to distribute instances across multiple JVMs. 

Reference: Programming restrictions on EJB 


Q37. A developer examines a list of potential enterprise applications and selects the most appropriate technologies to use for each application. 

For which two applications is EJB an appropriate solution? (Choose two.) 

A. To render a GUI for mobile clients. 

B. As a container for web-tier components including JSP. 

C. As a Web service endpoint accessed by non-Java clients. 

D. To receive and respond to HTTP Post requests directly from a web browser. 

E. As an online shopping cart which can persist across multiple sessions with a single client. 

Answer: CE 


Q38. Given Singleton bean FooEJB: 

FooEJB is packaged as the only bean in an ejb-jar and deployed to a server instance. Which represents the output generated from FooEJB after the deployment has completed? 

A. Init 

B. foo 

C. Init foo 

D. <no output> 

E. a or d 

Answer: A 

Explanation: Note: 

* The PostConstruct annotation is used on a method that needs to be executed after dependency injection is done to perform any initialization. This method MUST be invoked before the class is put into service. This annotation MUST be supported on all classes that support dependency injection. The method annotated with PostConstruct MUST be invoked even if the class does not request any resources to be injected. Only one method can be annotated with this annotation. The method on which the PostConstruct annotation is applied MUST fulfill all of the following criteria - -The method MUST NOT have any parameters except in the case of EJB interceptors in which case it takes an InvocationC ontext object as defined by the EJB specification. - The return type of the method MUST be void. - The method MUST NOT throw a checked exception. - The method on which PostConstruct is applied MAY be public, protected, package private or private. - The method MUST NOT be static except for the application client. - The method MAY be final. - If the method throws an unchecked exception the class MUST NOT be put into service except in the case of EJBs where the EJB can handle exceptions and even recover from them. 

* PostConstruct methods are invoked on the newly constructed instance, after any dependency injection has been performed by the container and before the first business method is invoked on the bean. 


Q39. Which statement about message-driven beans is correct? 

A. Each message-driven bean instance will be invoked by only one thread at a time. 

B. When dispatching messages to message beam instances the container must preserve the order in which messages arrive. 

C. If a message-driven bean is associated with a JMS queue, each bean instance in the pool will receive each message sent to the queue. 

D. If a message driven bean is associated with a JMS durable subscription, each bean instance in the pool will receive each message sent to the durable subscription. 

Answer: A 


Q40. Which statement is true about both stateful session beans and stateless session beans? 

A. Bean instance are NOT required to survive container crashes. 

B. Any bean instance must be able to handle concurrent invocations from different threads. 

C. A bean with bean-managed transactions must commit or roll back any transaction before returning from a business method. 

D. The container passivates and actives them using methods annotated with @PrePassivate and @PostActivate annotations. 

Answer: AC 

Explanation: 

Note: 

* Session beans can either be stateful or stateless. With stateful beans, the EJB container saves internal bean data during and in between method calls on the client’s behalf. With stateless beans, the clients may call any available instance of an instantiated bean for as long as the EJB container has the ability to pool stateless beans. This enables the number of instantiations of a bean to be reduced, thereby reducing required resources. 

Incorrect: 

B: Stateful session beans maintain state both within and between transactions. Each stateful session bean is therefore associated with a specific client. 

D: @PrePassivate(javax.ejb.PrePassivate) : 

If a stateful session bean instance is idle for too long, the container might passivate it and store its state to a cache. 

The method tagged by this annotation is called before the container passivates the bean instance. 

This annotation is only applicable to stateful session beans.