[Free] 2017(Jan) EnsurePass Pass4sure Oracle 1z0-895 Dumps with VCE and PDF 21-30

Ensurepass.com : Ensure you pass the IT Exams
2017 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: 21

A developer writes a stateful session bean FooBean with two local business interfaces Foo and bar. The developer wants to write a business method called getBar for interface Foo that returns a Bar reference to the same session bean identity on which the client onvokes getBar.

Which code, when inserted on line 12 below implements the getBar method with the wanted behavior?

  1. @Resource SessionContext sessionCtx;

  2. public Bar getbar () { 12.

13. }

  1. Return (bar) this;

  2. Return (bar) new FooBarBean();

  3. Return (bar) sessionCtx.lookup(“FooBarBean”)

  4. Return (bar) sessionCtx.getBusinessObject(Bar.class);

  5. Return (bar) session Ctx.lookup(“java: comp/env/ejb/FooBarBean”);

Answer: D

Question No: 22

Given the following code in an EJB session bean:

Ensurepass 2017 PDF and VCE

Which code, inserted at Line 15, portably looks up the injected resource?

  1. Object obj = ic.lookup (“employeeDB”);

  2. Object obj = ic.lookup (“dataSource”);

  3. Object obj = ic.lookup (“jdbc/employeeDB”);

  4. Object obj = ic.lookup (“java:comp/env/employeeDB”);

  5. Object obj= ic.lookup (“java:cmp/env/jdbc/employeeDB);

Answer: E

Question No: 23

A developer is writing client code to access a session bean deployed to a server instance.

The client can access the session bean under which of these circumstances? (Choose three)

  1. The client is deployed in the same JVM as the session bean and the session bean has a local interface.

  2. The client is deployed in the same JVM as the session bean and the session bean exposes a no-interface view.

  3. The client is deployed in a different JVM from the session bean and the session bean has a local interface.

  4. The client is deployed in a different JVM from the session bean and the session bean has a remote interface.

  5. The client is deployed in a different JVM from the session bean and the session bean has a no-interface implementation.

Answer: A,B,D

Explanation: D: If your architecture has a requirement whereby the client application (web application or rich client) has to run on a different JavaVirtual Machine (JVM) from the one that is used to run the session beans in an EJB container, then you need to use the remote interface.

Question No: 24

A developer writes three interceptor classes: AInt, BInt, and CInt. Each interceptor class defines an AroundInvoke method called interceptor. In the ejb-jar.xml descriptor, CInt is declared as the default interceptor.

FooBean is a stateless session bean with a local business interface Foo that declares a method Foo ():

  1. @Stateless

  2. @Interceptors(AInt.class)

  3. public class FooBean Implements Foo { 13.

  1. @Interceptors (BInt.class)

  2. @ExcludeClassInterceptors

  3. public void foo () {}

17. }

What is the interceptor order when the business method foo () is invoked?

  1. BInt

  2. CInt, BInt

  3. CInt, AInt, BInt

  4. BInt, AInt, CInt

Answer: B

Explanation: The default Intercepter, CInt, comes first. The class intercepter AInt is excluded by @ExcludeClassInterceptors, so the Method Intercepter BInt would be next in order.

Note 1: By default the ordering of interceptors when invoking a method are

* External interceptors

** Default interceptors, if present

** Class interceptors, if present

** Method interceptors, if present

*Bean class interceptor method

Note 2: Annotation Type ExcludeClassInterceptors

Used to exclude class-level interceptors for a business method or timeout method of a target class.

Reference: EJB Interceptors

http://docs.jboss.org/ejb3/app-server/tutorial/interceptor/interceptor.html

Question No: 25

An ejb-jar also contains three interceptor classes: AInt, BInt, CInt. Each interceptor class defines an AroundInvoke method called intercept.

The ejb-jar also contains a stateless session bean FooBean with a local business interface Foo that declares a method foo ():

  1. @Stateless

  2. @Intercaptors ({CInt.class, BInt.class})

  3. public class FooBean implements Foo { 13.

14. public void foo () {}

15.

16. }

The ejb-jar contains a META-INF/ejb-jar.xml file with an lt;interceptor-bindinggt; section:

lt;interceptor-bindinggt;

lt;ejb-namegt;FooBeanlt;/ejb-namegt;

lt;interceptor-ordergt;

lt;interceptor.classgt;com.acme.AIntlt;/interceptor-classgt;

lt;/interceptor-ordergt;

lt;/interceptor.bindinggt;

What is the interceptor order when the business methodfoo() is invoked?

  1. AInt

  2. AInt, CInt, BInt

  3. CInt, BInt, AInt

  4. AInt, BInt, CInt

Answer: B

Explanation: With the interceptor-order clauses Aint will be first in the order of interceptors.

Within each group (default, class, method) the order of the interceptors are from left to right as defined in the @Interceptors annotation, and then the xml interceptors.

In this scenario, with the @Intercaptors ({CInt.class, BInt.class}) line, the ordering continues with CInt and BInt.

Note 1: By default the ordering of interceptors when invoking a method are

* External interceptors

** Default interceptors, if present

** Class interceptors, if present

** Method interceptors, if present

*Bean class interceptor method

Note 2: You can override the default sort order of the external interceptors by specifiying an interceptor-binding with an interceptor-order specifying the order of the interceptors

Reference: EJB Interceptors

http://docs.jboss.org/ejb3/app-server/tutorial/interceptor/interceptor.html

Question No: 26

How many interceptor classes can be applied to a single stateful session bean?

  1. a maximum of one

  2. any number may be applied

  3. one for each business method

  4. one for each business interface

Answer: B

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

Question No: 27

A developer writes an interceptor class called FooInterceptor containing the following AroundInvoke method:

  1. @AroundInvoke

  2. public Object intercept (InvocationContext ctx) {

  3. return “intercepted”;

14. }

FooInterceptor is applied to a business method in a stateless session bean:

  1. @Interceptors (FooInterceptor.class)

  2. public String testzero(int i) {

  3. return (i = = 0) ? “zero”: “not zero”

14. }

Which describes the result when a client invokes the testzero method with a value of 1?

  1. The interceptor method is NEVER invoked.

  2. The clientreceives a return value of “zero”.

  3. The client receives a return value of “not zero”.

  4. The client receives a return value of “intercepted”.

Answer: D

Question No: 28

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?

  1. @Asynchronous

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

  2. @Asynchronous Future lt;voidgt; bar () { . . .}

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

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

Answer: B

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 Futurelt;Stringgt; ejbAsynchronousSayHello(String name){

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

Question No: 29

Which is true about caller security principal propagation for asynchronous EJB method Invocations?

  1. Caller security principal propagates along with an asynchronous EJB method invocation.

  2. Caller security principal does not propagate along with an asynchronous EJB method invocation.

  3. Caller security principal propagates along with an asynchronous EJB method invocation only if the target bean has at least one protected method.

  4. Caller security principal propagates along with an asynchronous EJB method invocation only if the calling bean has at least one protected method.

Answer: D

Explanation: One important caveat of asynchronous method invocation is that transactions are not propagated to the asynchronous method-a new transaction will be started for the asynchronous method. However, unlike transactions, the security principal will be propagated.

Declarative security is based only on the principal and the method being invoked, whereas programmatic security can take state into consideration.

Question No: 30

A bean developer writes a stateless session bean FooEJB with the following asynchronous business method:

@Asynchronous

public Futurelt;Integergt; fooAsync () { System.out.printIn (“begin”);

int i = 1; System.out.print(“end”);

Return new AsyncResultlt;Integergt; (i);

}

Given the following code, where fooRef is an EJB reference to FooEJB: Futurelt;Integergt; fooFuture = fooref.fooAsync();

fooFuture.cancel (true);

Which two represents possible system output after all processing has completed? (Choose two)

  1. Begin end

  2. Begin

  3. End

  4. 1

  5. lt;no outputgt;

Answer: D,E

Explanation: Either it will run and return 1, or it will be cancelled and produce no output. Note:EJB 3.1 can support a return type of java.util.concurrent.Futurelt;Vgt;, where V

represents the resultant value of an asynchronous invocation. In case you are unfamiliar with it, the Futurelt;Vgt; interface allows you to do things like cancelling an asynchronous invocation, checking if an invocation is complete, check for exceptions and getting the results of an asynchronous invocation.

100% Ensurepass Free Download!
Download Free Demo:1z0-895 Demo PDF
100% Ensurepass Free Guaranteed!
Download 2017 EnsurePass 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

2017 EnsurePass IT Certification PDF and VCE

Leave a Reply

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