• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

OCPJBCD Mock Exam – 2

February 6, 2014 //  by Krishna Srinivasan//  Leave a Comment

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.

Category: CertificationsTag: OCPJBCD

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.

Previous Post: « OCPJBCD Mock Exam -1
Next Post: OCPJBCD Mock Exam – 3 »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact