Oracle 1z0-895 Exam Practice Questions (P. 5)
- Full Access (90 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #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?
10. @Resource SessionContext sessionCtx;
11. public Bar getbar () {
12.
13. }
Which code, when inserted on line 12 below implements the getBar method with the wanted behavior?
10. @Resource SessionContext sessionCtx;
11. public Bar getbar () {
12.
13. }
- AReturn (bar) this;
- BReturn (bar) new FooBarBean();
- CReturn (bar) sessionCtx.lookup("FooBarBean")
- DReturn (bar) sessionCtx.getBusinessObject(Bar.class);
- EReturn (bar) session Ctx.lookup("java: comp/env/ejb/FooBarBean");
Correct Answer:
D
D
send
light_mode
delete
Question #22
Given the following code in an EJB session bean:

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

Which code, inserted at Line 15, portably looks up the injected resource?
- AObject obj = ic.lookup ("employeeDB");
- BObject obj = ic.lookup ("dataSource");
- CObject obj = ic.lookup ("jdbc/employeeDB");
- DObject obj = ic.lookup ("java:comp/env/employeeDB");
- EObject obj = ic.lookup ("java:cmp/env/jdbc/employeeDB);
Correct Answer:
E
E
send
light_mode
delete
Question #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)
The client can access the session bean under which of these circumstances? (Choose three)
- AThe client is deployed in the same JVM as the session bean and the session bean has a local interface.
- BThe client is deployed in the same JVM as the session bean and the session bean exposes a no-interface view.
- CThe client is deployed in a different JVM from the session bean and the session bean has a local interface.
- DThe client is deployed in a different JVM from the session bean and the session bean has a remote interface.
- EThe client is deployed in a different JVM from the session bean and the session bean has a no-interface implementation.
Correct Answer:
ABD
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.
ABD
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.
send
light_mode
delete
Question #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 ():
10. @Stateless
11. @Interceptors(AInt.class)
12. public class FooBean Implements Foo {
13.
14. @Interceptors (BInt.class)
15. @ExcludeClassInterceptors
16. public void foo () {}
17. }
What is the interceptor order when the business method foo () is invoked?
FooBean is a stateless session bean with a local business interface Foo that declares a method Foo ():
10. @Stateless
11. @Interceptors(AInt.class)
12. public class FooBean Implements Foo {
13.
14. @Interceptors (BInt.class)
15. @ExcludeClassInterceptors
16. public void foo () {}
17. }
What is the interceptor order when the business method foo () is invoked?
- ABInt
- BCInt, BInt
- CCInt, AInt, BInt
- DBInt, AInt, CInt
Correct Answer:
B
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
B
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
send
light_mode
delete
Question #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 ():
10. @Stateless
11. @Intercaptors ({CInt.class, BInt.class})
12. 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 <interceptor-binding> section:
<interceptor-binding>
<ejb-name>FooBean</ejb-name>
<interceptor-order>
<interceptor.class>com.acme.AInt</interceptor-class>
</interceptor-order>
</interceptor.binding>
What is the interceptor order when the business methodfoo() is invoked?
The ejb-jar also contains a stateless session bean FooBean with a local business interface Foo that declares a method foo ():
10. @Stateless
11. @Intercaptors ({CInt.class, BInt.class})
12. 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 <interceptor-binding> section:
<interceptor-binding>
<ejb-name>FooBean</ejb-name>
<interceptor-order>
<interceptor.class>com.acme.AInt</interceptor-class>
</interceptor-order>
</interceptor.binding>
What is the interceptor order when the business methodfoo() is invoked?
- AAInt
- BAInt, CInt, BInt
- CCInt, BInt, AInt
- DAInt, BInt, CInt
Correct Answer:
B
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
B
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
send
light_mode
delete
All Pages