[Free] 2018(Jan) EnsurePass Testinsides Oracle 1z0-895 Dumps with VCE and PDF 11-20

By | January 25, 2018

Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-895
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-895.html

Java EE 6 Enterprise JavaBeans Developer Certified Expert Exam

Question No: 11

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

  1. The bean class may declare instance variables.

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

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

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

Answer: A,C

Explanation: * A: Stateless session beans are EJB#39;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#39;t mean that a stateless session bean can#39;t have instance variables and therefore some kind of internal state. There#39;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#39;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#39;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.

Question No: 12

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

  1. The cleanup method may declare checked exceptions.

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

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

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

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

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

Answer: B,C,D

Question No: 13

A developer creates a stateless session bean. This session bean needs data from a remote system. Reading this data takes a long time. Assume that the data will NOT change during the life time of the bean and that the information to connect to the remote system is defined in JNDI.

Which statement describes how to manage the data correctly?

  1. Read the data in the bean#39;s constructor.

  2. The data can only be read in the bean#39;s business methods.

  3. Read the data in a method which is annotated with @PrePassivate.

  4. Read the data in a method which is annotated with @PostActivate.

  5. Read the data in a method which is annotated with @PostConstruct.

Answer: E

Question No: 14

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

Ensurepass 2018 PDF and VCE

Which HelloWorldBean methods are accessible by another EJB within the same ejb-jar?

  1. All of the methods declared in HelloWorldBean

  2. All of the methods declared in HelloWorld and HelloWorldBean

  3. All of the public methods declared in HelloWorldBean

  4. All of the public methods declared in HelloWorld andall of the methods declared in HelloWorldBean

Answer: C

Question No: 15

Given the following stateless session bean:

Ensurepass 2018 PDF and VCE

How would you change the EJB to prevent multiple clients from simultaneously accessing the sayHello method of a single bean instance?

  1. Convert sayHello into a synchronized method

  2. Execute the call to generateLocalizedHello in a synchronized block

  3. Convert generateLocalizehello into a synchronized method

  4. Convert HelloWordBean into a singleton bean

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

    Question No: 16

    Given singleton bean FooEJB:

    Ensurepass 2018 PDF and VCE

    How many distinct FooEJB bean instances will be used to process the code on the lines 101-105?

    1. 0

    2. 1

    3. 2

    Answer: B

    Explanation: Java has several design patterns Singleton Pattern being the most commonly used. Java Singleton pattern belongs to the family of design patterns, that govern the instantiation process. This design pattern proposes that at any time there can only be one instance of a singleton (object) created by the JVM.

    Question No: 17

    A developer writes a Singleton bean that holds state for a single coordinate:

    Ensurepass 2018 PDF and VCE

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

    Explanation: The value could be either [0,0] or [1,1].

    Note:

    Java has several design patterns Singleton Pattern being the most commonly used. Java Singleton patternbelongs to the family of design patterns, that govern the instantiation process. This design pattern proposes that at any time there can only be one instance of a singleton (object) created by the JVM.

    Question No: 18

    Assume a client will be accessing a Singleton bean.

    Which client views is a Singleton bean capable of exposing? (Choose two)

    1. Web Service

    2. Message listener

    3. EJB 2.x Remote Home

    4. EJB 3.x local business

    5. Java Persistence API entity

    Answer: A,B

    Explanation: Singleton session beans are appropriate in the following circumstances.

  • State needs to be shared across the application.

  • A single enterprise bean needs to be accessed by multiple threads concurrently.

  • The application needs an enterprise bean to perform tasks upon application startup and shutdown.

  • The bean implements a web service. (A)

B: An interceptor method you define in a separate interceptor class takes an invocation context as argument: using this context, your interceptor method implementation can access details of the original session bean business method or message-driven bean message listener method invocation.

Singleton Interceptors

If your interceptors are stateless, you can use an OC4J optimization extension to the EJB

3.0 specification that allows you to specify singleton interceptors. When you configure a session bean or message-driven bean to use singleton interceptors and you associate the bean with an interceptor class, OC4J creates a single instance of the interceptor class that all bean instances share. This can reduce memory requirements and life cycle overhead.

Note:

Singleton session beans offer similar functionality to stateless session beans but differ from them in that there is only one singleton session bean per application, as opposed to a pool of stateless session beans, any of which may respond to a client request. Like stateless session beans, singleton session beans can implement web service endpoints.

Reference: The Java EE 6 Tutorial, What Is a Session Bean?

Reference: Oracle Containers for J2EE Enterprise JavaBeans Developer#39;s Guide, How do you use an Enterprise Bean in Your Application

Question No: 19

A developer writes a Singleton bean that uses the java Persistence API within a business method:

Ensurepass 2018 PDF and VCE

Two different concurrently executing caller threads acquire an EJB reference to PersonBean and each invoke the getPerson () method one time. How many distinct transaction are used to process the caller invocations?

  1. 0

  2. 1

  3. 2

Answer: B

Explanation: Only one transaction is required. LockType READ allows simultaneous access to singleton beans.

Note: READ

public static final LockType READ

For read-only operations. Allows simultaneous access to methods designated as READ, as long as no WRITE lock is held.

Reference: javax.ejb, Enum LockType

Question No: 20

Given the following client-side code that makes use of the session bean Foo:

10. @EJB Foo bean1;

12. @EJB Foo bean2;

// more code here

  1. boolean test1 = beanl.equals(bean1);

  2. boolean test2 = beanl.equals(bean2) ; Which three statements are true? (Choose three)

  1. If Foo is stateful, test1 is true, and test2 is true.

  2. If Foo is stateful, test1 is true, and test2 is false.

  3. If Foo is stateless, test1 is true, and test2 is true.

  4. If Foo is stateless, test1 is true, and test2 is false.

  5. If Foo is singleton, test1 is true, and test2 is true.

  6. If Foo is singleton, test1 is true, and test2 is false.

Answer: B,C

100% Ensurepass Free Download!
Download Free Demo:1z0-895 Demo PDF
100% Ensurepass Free Guaranteed!
1z0-895 Dumps

EnsurePass ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
PDF VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.