OCPJBCD Mock Exam – 2

1 . Can we use the annotation @PrePassivate for more than one method in a bean?

  1. Yes
  2. No

2 . What should be the return type of the method using @PrePassivate?

  1. Object
  2. void
  3. String
  4. boolean

3 . Which of the following are correct statements about @PrePassivate?

  1. Method’s return value must not be void
  2. Method cannot be private
  3. The method must not be final
  4. The method must not throw a checked exception
  5. All of the above

4 . Which of the following callbacks are called during the passivattion and activation process?

  1. @PostConstruct
  2. @PostActivation
  3. @PrePassive
  4. @PostActivate

5 . Which of the following call backs are called for the stateful session bean?

  1. Construction
  2. Destruction
  3. Activation
  4. Passivation
  5. All the above

6 . Which of the following call backs are supported for the stateless session bean?

  1. post construction
  2. pre destroy
  3. passivation
  4. activation
  5. All of the above

7 . Which of the following statements are true about interceptors?

  1. Interceptor can not invoke JMS
  2. Interceptor class must have a public no-arg constructor
  3. Interceptor instance can not be created when the Bean instance is created
  4. Interceptor can invoke JNDI

8 . Extended persistence context support is only for interceptors associated with stateful session beans?

  1. False
  2. True

9 . Which of the following annotations are related to configuring the interceptors?

  1. @AroundInvoke
  2. @ExcludeClassInterceptors
  3. @ExcludeDefaultInterceptors
  4. @Interceptors
  5. All of the above

10 . Which of the following are the valid statements for @AroundInvoke?

  1. AroundInvoke method cannot be a business method of the bean
  2. AroundInvoke method can invoke any resource tha a business method can access
  3. AroundInvoke method can be declared as final
  4. 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.

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*