Oracle 1z0-895 Exam Practice Questions (P. 3)
- 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 #11
Which two statements are correct about stateless session beans? (Choose two.)
- AThe bean class may declare instance variables.
- BThe lifetime of the bean instance is controlled by the client.
- CThe container may use the same bean instance to handle multiple business method invocations at the same time.
- DThe container may use the same bean instance to handle business method invocations requested by different clients, but not concurrently.
Correct Answer:
AD
* 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.
AD
* 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.
send
light_mode
delete
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.)
Which three statements are correct? (Choose three.)
- AThe cleanup method may declare checked exceptions.
- BThe cleanup method must have no arguments and return void.
- CThe cleanup method is executed in an unspecified transaction and security context.
- DThe developer should mark the cleanup method with the @PreDestroy annotation.
- EThe developer should mark the cleanup method with the @PostDestroy annotation.
- FThe cleanup method is executed in the transaction and security context of the last business method Invocation.
Correct Answer:
BCD
BCD
send
light_mode
delete
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?
Which statement describes how to manage the data correctly?
- ARead the data in the bean's constructor.
- BThe data can only be read in the bean's business methods.
- CRead the data in a method which is annotated with @PrePassivate.
- DRead the data in a method which is annotated with @PostActivate.
- ERead the data in a method which is annotated with @PostConstruct.
Correct Answer:
E
E
send
light_mode
delete
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?

Which HelloWorldBean methods are accessible by another EJB within the same ejb-jar?
- AAll of the methods declared in HelloWorldBean
- BAll of the methods declared in HelloWorld and HelloWorldBean
- CAll of the public methods declared in HelloWorldBean
- DAll of the public methods declared in HelloWorld and all of the methods declared in HelloWorldBean
Correct Answer:
C
From JSR318 Enterprise JavaBeans 3.1, Final Release
4.9.6 Business Methods
The business method must be declared as public.
4.9.7 Session Beans Business Interface
If the bean does not expose any other business interfaces (Local, Remote) or No-Interface view, and the bean class implements a single interface, that interface is assumed to be the business interface of the bean. This business interface will be a local interface unless the interface is designated as a remote business interface by use of the Remote annotation on the bean class or interface or by means of the deployment descriptor.
4.9.8 Session Beans No-Interface View
If the bean exposes at least one other client view, the bean designates that it exposes a no-interface view by means of the @LocalBean annotation on the bean class or in the deployment descriptor.
All public methods of the bean class and any superclasses are exposed as business methods through the no-interface view
C
From JSR318 Enterprise JavaBeans 3.1, Final Release
4.9.6 Business Methods
The business method must be declared as public.
4.9.7 Session Beans Business Interface
If the bean does not expose any other business interfaces (Local, Remote) or No-Interface view, and the bean class implements a single interface, that interface is assumed to be the business interface of the bean. This business interface will be a local interface unless the interface is designated as a remote business interface by use of the Remote annotation on the bean class or interface or by means of the deployment descriptor.
4.9.8 Session Beans No-Interface View
If the bean exposes at least one other client view, the bean designates that it exposes a no-interface view by means of the @LocalBean annotation on the bean class or in the deployment descriptor.
All public methods of the bean class and any superclasses are exposed as business methods through the no-interface view
send
light_mode
delete
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?

How would you change the EJB to prevent multiple clients from simultaneously accessing the sayHello method of a single bean instance?
- AConvert sayHello into a synchronized method
- BExecute the call to generateLocalizedHello in a synchronized block
- CConvert generateLocalizehello into a synchronized method
- DConvert HelloWordBean into a singleton bean
- ENo changes are needed
Correct Answer:
E
Reference: The Java Tutorial, Synchronized Methods
E
Reference: The Java Tutorial, Synchronized Methods
send
light_mode
delete
All Pages