GOOD NEWS: You can free download 100% accurate Oracle 1Z1-895 practice test for training on Flydumps.com.Flydumps is also an authenticated IT certifications site that offers all the new Oracle 1Z1-895 questions and answers timely.Visit the site Flydumps.com to get free Oracle 1Z1-895 VCE and PDF.
QUESTION 1
A developer needs to deliver a large-scale enterprise application that connects developer chooses an EJB 3.1-compliant application server, which three are true about the EJB business component tier? (Choose three.)
A. Load-balancing is NOT a guarantee for all EJB 3.1 containers.
B. Clustering is guaranteed to be supported by the EJB 3.1 container.
C. Thread pooling can be optimized by the Bean Provider programmatically.
D. Bean Providers are NOT required to write code for transaction demarcation.
E. Support for server fail-over is guaranteed for an EJB 3.1-compliant application server.
F. EJB 3.1 compliant components are guaranteed to work within any Java EE 6 application server
Correct Answer: ACF Explanation
Explanation/Reference:
The EJB tier hosts the business logic of a J2EE application and provides system-level services to the business components problems include state maintenance, transaction management, and availability to local and remote clients.
The EJB 3.1 specification does not address “high-end” features like clustering (not B), load-balancing (A) and fail-over (not E).
F: The target platform for EJB is Java EE.
QUESTION 2
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.
Correct Answer: CE Explanation
Explanation/Reference:
QUESTION 3
Which two statements are true? (Choose two.)
A. Typically, remotely accessible objects should be coarse-grained.
B. If a client accesses an enterprise bean locally such access must be mediated by the EJB container.
C. A given enterprise bean’s transaction information is immutable because it is deployed across various containers.
D. If a container provides services NOT required by the EJB specification, then that container is NOT considered to be an EJB container.
E. An enterprise bean’s transaction Information can be accessed by external tools only if the information is contained in an XML deployment descriptor.
Correct Answer: BD Explanation Explanation/Reference:
D: An EJB container is nothing but the program that runs on the server and implements the EJB specifications. EJB container provides special type of the environment suitable for running the enterprise components. Enterprise beans are used in distributed applications that typically contains the business logic.
Incorrect answers:
A: Remotely accessible objects should be fine-grained
QUESTION 4
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
Correct Answer: B Explanation
Explanation/Reference:
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
QUESTION 5
Which API must an EJB 3.1 container make available to enterprise beans at runtime? (Choose one)
A. The JXTA 1.1 API
B. The MIDP 2.0 API
C. The Java SE 6 JNDI API
D. The Java SE 5 JDBC API
Correct Answer: CD Explanation Explanation/Reference:
QUESTION 6
A developer wants to write a stateful session bean using the following interface as local business interface:
1.
package acme;
2.
public interface Bar {
3.
public void bar ();
4.
}
Assuming there is not an ejb-jar.xml file, which code can be inserted into Lines 4-6 below to define the
bean with the ejb name of BarBean?
1.
package acme;
2.
import javax.ejb.*;
3.
import java.io.*;
4.
5.
6.
7.
}
A. @Stateful public class BarEJB implements Bar { public void bar () {}
B. @Stateful (name = “Bar”) public class Barbean implements Bar { public void bar () {}
C. @Stateful public class BarBean implements Serializable, Bar { public void bar () {}
D. @Stateful (name = “bar”) public class BarBean implements Serializable, Bar { public void bar () throws java.rmi.RemoteException {}
Correct Answer: C Explanation
Explanation/Reference:
QUESTION 7
A developer creates a stateful session bean that is used by many concurrent clients. The clients are written
by other development team; and it is assumed that these clients might not remove the bean when ending
their session. The number of concurrent sessions will be greater than the defined bean cache size.
The developer must consider that the state of the session bean can be influenced by either passivation or
timeout.
Which three actions should the developer take to make the bean behave correctly in passivation and
timeout situations? (Choose three.)
A. Release references to resources in a @Remove annotated method.
B. Re-establish references to resources in an @Init annotated method.
C. Release references to resources in a @PreDestroy annotated method.
D. Release references to resources in a @PrePassivate annotated method.
E. Re-establish references to resources in a @PostActivate annotated method.
Correct Answer: CDE Explanation
Explanation/Reference: QUESTION 8
A stateful session bean contains a number of instance variables. The types of instance variables A and B are serializable. Instance variable B is a complex type which is populated by many business calls, and can, therefore, not be refilled by the client without starting all over. A helper instance variable C is defined as having a Serializable type, and can hold all the information which is in variable B. for example, B is of type XML-DOM tree and C of Type String.
Which two solutions, when combined, maintain the state of the session bean over a passivation and activation by the container? (Choose two.)
A. The value of helper variable C is used to create the value of Instance variable B in the beans no-arg constructor.
B. The value of helper variable C is used to create the value of instance variable B in a @postcreate annotated method.
C. The value of helper variable C is used to create the value of instance variable B in a @postActivate annotated method.
D. Instance variable A must be made null and instance variable B must be converted to a Serializable type and assigned to another instance variable in a @preDestroy annotated method.
E. Instance variable A must be defined transient. Instance variable B must be converted to a Serializable type, set to null, and assigned to the instance variable C in a @PrePassivate annotated method.
Correct Answer: CE Explanation
Explanation/Reference:
QUESTION 9
A developer writes a stateful session bean FooBean with one remote business interface Foo. Foo defines an integer / setter method pair implemented as:
10.
private int value;
11.
public void setValue (int i) {value = i; }
12.
public int getValue () {return value; }
A session bean ClientBean has a business method doSomething and an ejb-ref with ejb-ref-name “fooRef” that is mapped to FooBean’s Foo interface.
11.
@Resource private SessionContext SessionCtx;
12.
public void doSomething () {
13.
Foo foo1 = (Foo) sessionCtx.lookup(“fooRef”);
14.
Foo foo2 = (Foo) sessionCtx.lookup(“fooRef”);
15.
foo1.setvalue(1);
Which statement is true after the code at line 15 completes?
A. Foo1.getValue () = = 0 and foo2.getValue() = = 0
B. Foo1.getValue () = = 0 and foo2.getValue() = = 1
C. Foo1.getValue () = = 1 and foo2.getValue() = = 0
D. Foo1.getValue () = = 1 and foo2.getValue() = = 1
Correct Answer: D Explanation
Explanation/Reference:
Foo1 and Foo2 references the same object.
QUESTION 10
A developer writes a stateless session bean FooBean with one remote business interface FooRemote containing one business method foo. Method foo takes a single parameter of application-defined type MyData.
11.
public class MyData implements java.io.Serialization {
12.
int a;
13.
}
Methods foo is implemented with the FooBean class as:
11.
public void foo (MyData data) {
12.
data.a = 2;
13.
}
Another session bean within the same application has a reference to FooRemote in variable fooRef and calls method foo with the following code:
11.
MyData data = new MyData();
12.
data.a = 1;
13.
fooRef.foo(data);
14.
System.out.printIn(data.a);
What is the value of data.a when control reaches Line 14 of the client?
A. 0
B. 1
C. 2
Correct Answer: B Explanation
Explanation/Reference:
QUESTION 11
Which two statements are correct about stateless session beans? (Choose two.)
A. The bean class may declare instance variables.
B. The lifetime of the bean instance is controlled by the client.
C. The container may use the same bean instance to handle multiple business method invocations at the same time.
D. The container may use the same bean instance to handle business method invocations requested by different clients, but not concurrently.
Correct Answer: AC Explanation
Explanation/Reference:
* A: Stateless session beans are EJB’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’t mean that a stateless session bean can’t have instance variables and therefore some kind of internal state. There’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.
A stateless session bean is relatively easy to develop and also very efficient.
C: Stateless session beans require few server resources because they are neither persistent nor dedicated to one client. Because they aren’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’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 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.)
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.
Correct Answer: BCD Explanation
Explanation/Reference:
QUESTION 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?
A. Read the data in the bean’s constructor.
B. The data can only be read in the bean’s business methods.
C. Read the data in a method which is annotated with @PrePassivate.
D. Read the data in a method which is annotated with @PostActivate.
E. Read the data in a method which is annotated with @PostConstruct.
Correct Answer: E Explanation
Explanation/Reference:
QUESTION 14
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 Correct Answer: C
Explanation Explanation/Reference:
QUESTION 15
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
Correct Answer: A Explanation
Explanation/Reference:
*
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 16
Given singleton bean FooEJB:
How many distinct FooEJB bean instances will be used to process the code on the lines 101-105?
A. 0
B. 1
C. 2
Correct Answer: B Explanation
Explanation/Reference:
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 17
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] Correct Answer: C
Explanation Explanation/Reference:
QUESTION 18
Assume a client will be accessing a Singleton bean.
Which client views is a Singleton bean capable of exposing? (Choose two)
A. Web Service
B. Message listener
C. EJB 2.x Remote Home
D. EJB 3.x local business
E. Java Persistence API entity
Correct Answer: AB Explanation Explanation/Reference:
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’s Guide, How do you use an
Enterprise Bean in Your Application
QUESTION 19
A developer writes a Singleton bean that uses the java Persistence API within a business method:
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?
A. 0
B. 1
C. 2
Correct Answer: B Explanation
Explanation/Reference:
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 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
20.
boolean test1 = beanl.equals(bean1);
Flydumps.com new Oracle 1Z1-895 brian dumps are designed to help you out in a short time. You can get Flydumps.com Oracle 1Z1-895 brain dumps to pass your exam.Our Oracle 1Z1-895 brain dumos will make your exam much easier.