Up to date Oracle 1Z0-895 – An Overview 41 to 50

Tested of 1Z0-895 test question materials and practice exam for Oracle certification for IT specialist, Real Success Guaranteed with Updated 1Z0-895 pdf dumps vce Materials. 100% PASS Java Platform, Enterprise Edition 6 Enterprise JavaBeans Developer Certified Expert Exam exam Today!

2016 Sep 1Z0-895 Study Guide Questions:

Q41. You are writing a client that sends a message to a JMS queue. Which statement is true? 

A. You use a connection factory to create a session. 

B. When you create a session, you specify whether or not it is transacted. 

C. When you create a connection, you specify the acknowledgment mode. 

D. When you create a message producer, you must specify the name of the destination to which you will send messages. 

Answer: A 

Explanation: Note: 

The SimpleMessageClient sends messages to the queue that the SimpleMessageBean listens to. 

The client starts by injecting the connection factory and queue resources: 

@Resource(mappedName="jms/ConnectionFactory") 

private static ConnectionFactory connectionFactory; 

@Resource(mappedName="jms/Queue") 

private static Queue queue; 

Next, the client creates the connection, session, and message producer: 

connection = connectionFactory.createConnection(); 

session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); 

messageProducer = session.createProducer(queue); 

Finally, the client sends several messages to the queue: 

message = session.createTextMessage(); 

for (int i = 0; i < NUM_MSGS; i++) { 

message.setText("This is message " + (i + 1)); 

System.out.println("Sending message: " + message.getText()); 

messageProducer.send(message); 

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

Answer: CE 

Q43. While excepting a business method in a stateless session bean the container rolls back the method’s transaction. Which three are possible causes for the container’s behavior? (Choose three.) 

A. The bean uses container-managed transactions and invokes EJBContext.setRollbackOnly. 

B. The bean uses container-managed transactions and invokes EJBContext.getRollbackOnly. 

C. The business method throws a java.lang.NullPointerException. 

D. The business method throws a checked exception of a class type that is marked with the @ApplicationException annotation with the rollback element value true. 

E. The business method throws a unchecked exception of a class type that is marked with the @ApplicationException annotation with the rollback element value true. 

F. The bean uses container-managed transactions and throws a checked exception of a class type that is marked with the @ApplicationException annotation with the rollback element value false. 

Answer: ADF 

Explanation: A: setRollbackOnly 

Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit. Only enterprise beans with container-managed transactions are allowed to use this method. 

Note: 

* In a stateless session bean with bean-managed transactions, a business method must commit or roll back a transaction before returning. 

* Bean-Managed Transactions In bean-managed transaction demarcation, the code in the session or message-driven bean explicitly marks the boundaries of the transaction. Although beans with container-managed transactions require less coding, they have one limitation: When a method is executing, it can be associated with either a single transaction or no transaction at all. If this limitation will make coding your bean difficult, you should consider using bean-managed transactions. 

* (incorrect) Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time. 

Incorrect: 

B: getRollbackOnly 

Test if the transaction has been marked for rollback only. An enterprise bean instance can use this operation, for example, to test after an exception has been caught, whether it is fruitless to continue computation on behalf of the current transaction. Only enterprise beans with container-managed transactions are allowed to use this method. 

1Z0-895  free question

Rebirth 1Z0-895 test question:

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

Answer: B 

Q45. A developer writes a stateful session bean with local business interface Bar containing method test. Method test is implemented as: 

11. @Remove 

12. public void test () {} 

A business method in a stateless session bean invokes a reference to bean Bar as follows: 

11. @EJB Bar bar; 

12. 

13. public void foo () { 

14. bar.test (); 

15. bar.test(); 

16. } 

Assuming execution reaches Line 15, what is the expected result? 

A. Method foo returns without error. 

B. A javax.ejb.NoSuchEJBException is thrown. 

C. A java.rmi.NoSuchObjectException is thrown. 

D. A javax.ejb.NoSuchEntityException is thrown. 

Answer: B 

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

Answer: D 

Explanation: Foo1 and Foo2 references the same object. 

1Z0-895  free question

Free 1Z0-895 testing engine:

Q47. Suppose developer wants to create an EJB component that performs data validation every hour. Given the following Stateless session bean: 

What is the minimum modification you would need to make to the bean to support notification from the TimerService once the timer expires? 

A. Modify the verify external orders method to look like this: 

@TimedOut 

private void verifyExternalOrders () { 

/ / do something 

B. Modify the verify external orders method to look like this: 

@EjbTimeOut 

private void verifyExternalOrders () { 

/ / do something 

C. Modify the verify external orders method to look like this: @ejbTimeOut private void verifyExternalOrders () { / / do something } 

D. Modify the verify external orders method to look like this: @TimeOut private void verifyExternalOrders () { / / do something } 

Answer: D 

Explanation: Programmatic Timers 

When a programmatic timer expires (goes off), the container calls the method annotated 

@Timeout in the bean’s implementation class. The @Timeout method contains the business logic that handles the timed event. 

The @Timeout Method 

Methods annotated @Timeout in the enterprise bean class must return void and optionally take a 

javax.ejb.Timer object as the only parameter. They may not throw application exceptions. 

@Timeout 

public void timeout(Timer timer) { 

System.out.println("TimerBean: timeout occurred"); 

Reference: The Java EE 6 Tutorial, Using the Timer Service 

Q48. A developer impalements an asynchronous implementation for calculating insurance proposals. The input data for the calculations is made available on a single message queue. Two types of insurance proposals will be calculated: car and life. Message with data for other insurance types are posted on the queue but should be left on the queue by this implementation. 

Which statement is true? 

A. The developer will NOT succeed because all messages will be consumed from the queue. 

B. The developer can implement a push-back mechanism if the message is of the wrong type. 

C. The developer can use a messageSelector to receive only the car and life data message if the JMS body contains selectable data. 

D. The developer can use a messageSelector to receive only the car and life data message if the header contains properties to make selection. 

Answer: D 

Explanation: A JMS message selector allows a client to specify, by header field references and property references, the messages it is interested in. Only messages whose header and property values match the selector are delivered. What it means for a message not to be delivered depends on the MessageConsumer being used (see QueueReceiver and TopicSubscriber). 

Reference: javax.jms Interface Message 

Q49. Assume you have been tasked with building an ejb-jar containing an EJB application. The EJB application contains local, remote, and web service and-point EJBs that provide reusable services within an enterprise. When the application is deployed clients 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.servicelayer package and are deployed as class files. The application uses a maximum of deployment descriptor and annotation configuration? 

A. Name the jar servicelayer.jar with the following structure: 

/ (Root) 

I – META – INF / 

I – MANIFEST.MF 

I – classes/ 

I – com/ 

I – acme/ 

I – servicelayer / 

<list of classes> 

B. Name the jar servicelayer.jar with the following structure: 

/ (Root) 

I – META – INF/ 

I – MANIFEST.MF 

I – ejb – jar.xml 

I – classes/ 

I – com/ 

I – acme / 

I – servicelayer/ 

<list of classes> 

C. Name the jar servicelayer.jar with the following structure: 

/(Root) 

I – META – INF / 

I – ejb – jar.xml 

I – com/ 

I – acme/ 

I – servicelayer/ 

<list of classes> 

D. Name the jar servicelayer.jar with the following structure: 

/ (Root) 

I – META – INF/ 

I – MANIFEST.MF 

I – ejb-jar.xml 

I – com/ 

I – servicelayer/ 

<list of classes> 

Answer: A 

Explanation: Structure of an Enterprise Bean JAR: 

Assembly Root 

ejb-jar.xml 

glassfish-ejb-jar.xml (optional, not used here Not D, Not C, not B)) 

META-INF 

MANIFEST.MF 

All .class files for this module 

References: The Java EE 6Tutorial, Packaging Enterprise Beans in EJB JAR Modules 

Q50. You have been tasked to build a jar file that can be used by a Java SE client to access the remote instance of the OrderProcessingBean. Given the following design: 

Which classes would need to be included in the client jar file? 

A. B, Order 

B. A, Order 

C. A, B, Order 

D. A, B, Order, OrderProcessingBean 

Answer: B 

Explanation: 

Note: 

* An EJB client JAR file is an optional JAR file that can contain all the class files that a client program needs to use the client view of the enterprise beans that are contained in the EJB JAR file. 

* If all your EJBs are in the same EAR then you can use local interfaces, if not you need remote interfaces. 

About 1Z0-895 Information: 1Z0-895 Dumps

Certleader Dumps
Certleader is a company specialized on providing high quality IT exam materials and fully committed to assist our respected clients crack any IT certification tests on their 1st efforts.