1 . Can we use the annotation @PrePassivate for more than one method in a bean?
- Yes
- No
2 . What should be the return type of the method using @PrePassivate?
- Object
- void
- String
- boolean
3 . Which of the following are correct statements about @PrePassivate?
- Method’s return value must not be void
- Method cannot be private
- The method must not be final
- The method must not throw a checked exception
- All of the above
4 . Which of the following callbacks are called during the passivattion and activation process?
- @PostConstruct
- @PostActivation
- @PrePassive
- @PostActivate
5 . Which of the following call backs are called for the stateful session bean?
- Construction
- Destruction
- Activation
- Passivation
- All the above
6 . Which of the following call backs are supported for the stateless session bean?
- post construction
- pre destroy
- passivation
- activation
- All of the above
7 . Which of the following statements are true about interceptors?
- Interceptor can not invoke JMS
- Interceptor class must have a public no-arg constructor
- Interceptor instance can not be created when the Bean instance is created
- Interceptor can invoke JNDI
8 . Extended persistence context support is only for interceptors associated with stateful session beans?
- False
- True
9 . Which of the following annotations are related to configuring the interceptors?
- @AroundInvoke
- @ExcludeClassInterceptors
- @ExcludeDefaultInterceptors
- @Interceptors
- All of the above
10 . Which of the following are the valid statements for @AroundInvoke?
- AroundInvoke method cannot be a business method of the bean
- AroundInvoke method can invoke any resource tha a business method can access
- AroundInvoke method can be declared as final
- AroundInvoke method cannot be static
Answers
1 : 2 is correct.
Explanation: Only one method in the bean class can be annotated with @PrePassivate. If you annotate more than one method with this annotations, the EJB will not deploy.
2 : 2 is correct.
Explanation: The return type of the method must be void.
3 : 3 & 4 is correct.
Explanation:
The following are the restrictions for the @PrePassivate method:
– The return type of the method must be void.
– The method must not throw a checked exception.
– The method may be public, protected, package private or private.
– The method must not be static.
– The method must not be final.
– This annotation does not have any attributes.
4 : 3 & 4 is correct.
5 : 5 is correct.
6 : 1 & 2 is correct.
7 : 2 & 4 is correct.
8 : 2 is correct.
9 : 5 is correct.
10 : 1,2 & 4 is correct.