It is more faster and easier to pass the Oracle 1Z0-895 exam by using Realistic Oracle Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam questuins and answers. Immediate access to the Renewal 1Z0-895 Exam and find the same core area 1Z0-895 questions with professionally verified answers, then PASS your exam with a high score now.

2021 Sep 1Z0-895 exams

Q51. Given a set of CMT bean methods with the following transaction attributes: 

Method M1 = SUPPORTS 

Method M2 = REQUIRED 


And the following method invocation sequence: 

Method Ml invokes Method M2 

Method M2 invokes Method M3 

Method M1 invokes Method M4 

If Method Ml is invoked by a method that does NOT have a transaction context, which describes a possible scenario? 

A. Method M1: no transaction Method M2: new transaction Method M3: no transaction Method M4: new transaction 

B. Method M1: no transaction Method M2: Container throws EJBTransactionRequiredException 

C. Method M1: new transaction Method M2: runs in same transaction as M1 Method M3: Container throws TransactionNotSupportedException 

D. Method M1: no transaction Method M2: new transaction Method M3: Container throws TransactionNotSupportedException 

Answer: A 

Q52. Suppose an EJB named HelloWorldBean is deployed as a standalone ejb-jar. Assuming the HelloWorldBean is implemented as follows: Which HelloWorldBean methods are accessible by another EJB within the same ejb-jar? 

A. All of the methods declared in HelloWorldBean 

B. All of the methods declared in HelloWorld and HelloWorldBean 

C. All of the public methods declared in HelloWorldBean 

D. All of the public methods declared in HelloWorld and all of the methods declared in HelloWorldBean 

Answer: C 

Q53. Assume you have been tasked with building an ejb-jar containing an EJB application. The EJB application contains local, remote, and web service end-point EJBs that provide reusable sevices within an enterprise. When the application is deployed, client will access the remote session beans using the global JNDI name java:ServiceLayer/<bean_name>. All of the EJBs are located in the com.acme.sevicelayer package and are deployed as class files. The application uses a mixture of deployment descriptor and annotation configuration. 

Which JAR representation best represents deployed structure for the previous requirements? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: C 



* JAR (Java ARchive) is an archive file format typically used to aggregate many Java class files and associated metadata and resources (text, images and so on) into one file to distribute application software or libraries on the Java platform. 

* JAR file is a file format based on the popular ZIP file format and is used for aggregating many files into one. A JAR file is essentially a zip file that contains an optional META-INF directory. 

* In the Java Platform, Enterprise Edition, a deployment descriptor describes how a component, module or application (such as a web application or enterprise application) should be deployed. It directs a deployment tool to deploy a module or application with specific container options, security settings and describes specific configuration requirements. XML is used for the syntax of these deployment descriptor files. 

For web applications, the deployment descriptor must be called web.xml and must reside in the WEB-INF directory in the web application root. For Java EE applications, the deployment descriptor must be named application.xml and must be placed directly in the META-INF directory at the top level of the application .ear file. 

* The existing.jar.tool is enhanced to be able to examine a list of jar files and generate directory information as to which classes and resources reside in which jar file. This directory information is stored in a simple text file of the root jar file. When the classloader loads the root jar file,.it reads the.INDEX.LIST.file and uses it to construct a hash table of mappings from file and package names to lists of jar file names. In order to find a class or a resource, the class loader queries the hashtable to find the proper jar file and then downloads it if necessary. 

* The INDEX.LIST file contains one or more sections each separated by a single blank line. Each section defines the content of a particular jar file, with a header defining the jar file path name, followed by a list of package or file names, one per line. All the jar file paths are relative to the code base of the root jar file. These path names are resolved in the same way as the current extension mechanism does for bundled extensions. 

Incorrect: Not A: No reference to the deployment descriptor file ejb-jar.xml Not D: No reference to classes 

Q54. A developer wants to release resources within a stateless session bean class. The cleanup method should be executed by the container before an instance of the class is removed. The deployment descriptor is NOT used. 

Which three statements are correct? (Choose three.) 

A. The cleanup method may declare checked exceptions. 

B. The cleanup method must have no arguments and return void. 

C. The cleanup method is executed in an unspecified transaction and security context. 

D. The developer should mark the cleanup method with the @PreDestroy annotation. 

E. The developer should mark the cleanup method with the @PostDestroy annotation. 

F. The cleanup method is executed in the transaction and security context of the last business method Invocation. 

Answer: BCD 

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

Renew 1Z0-895 exams:

Q56. An enterprise bean has security permissions set up using declarative security features. 

Under which two conditions can a client be guaranteed to have permission to invoke a business method on the enterprise bean? (Choose two.) 

A. The Application Assembler has marked the enterprise bean method as unchecked. 

B. The client's principal has been assigned a security role with permission to invoke the method. 

C. The Application Assembler has set the security-identity deployment descriptor to run-as. 

D. The Application Assembler has mapped all security role references using the role-link element. 

Answer: AB 

Q57. 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: B 

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. 


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

Q59. MyMsg is a JMS message-driven bean with container-managed transaction demarcation. FooBean is an EJB 3.x stateless session bean that sends message to the JMS destination with MyMsgBean is associated. 

MyMsgBean’s message listener method has transaction attribute REQUIRED, and is defined as follows: 

10. public class MyMsgBean implements javax.jms.messageListener { 

11. public void onMessage(javax.jms.Message message) { 

12. / / do some work not shown here 

13. thrown new RuntimeException(“unexpected error . . . ”); 

14. } 

Which statement is true about the result of message processing? 

A. FooBean receives javax.ejb.EJBException. 

B. The container discards the MyMsgBean bean instance. 

C. FooBean receives the original RuntimeException thrown from the message listener method. 

D. The container does NOT roll back the transaction, and FooBean can continue the transaction. 

Answer: C 


Note: public interface MessageListener 

A MessageListener object is used to receive asynchronously delivered messages. 

Each session must insure that it passes messages serially to the listener. This means that a listener assigned to one or more consumers of the same session can assume that the onMessage method is not called with the next message until the session has completed the last call. 

Reference: Enum TransactionAttributeType 

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





Answer: C 



* 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