- EJB Tutorial
- EJB - Home
- EJB - Overview
- EJB - Environment Setup
- EJB - Create Application
- EJB - Stateless Bean
- EJB - Stateful Bean
- EJB - Persistence
- EJB - Message Driven Beans
- EJB - Annotations
- EJB - Callbacks
- EJB - Timer Service
- EJB - Dependency Injection
- EJB - Interceptors
- EJB - Embeddable Objects
- EJB - Blobs/Clobs
- EJB - Transactions
- EJB - Security
- EJB - JNDI Bindings
- EJB - Entity Relationships
- EJB - Access Database
- EJB - Query Language
- EJB - Exception Handling
- EJB - Web Services
- EJB - Packaging Applications
- EJB Useful Resources
- EJB - Quick Guide
- EJB - Useful Resources
- EJB - Discussion
EJB Mock Test
This section presents you various set of Mock Tests related to EJB Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
EJB Mock Test III
Q 1 - Which of the following is true about callbacks in EJB?
A - Callback is a mechanism by which life cycle of an enterprise bean can be intercepted.
B - EJB Container calls callbacks.
C - We can define callback methods in the ejb class itself or in a separate class.
Answer : D
Explaination
Callback is a mechanism by which life cycle of an enterprise bean can be intercepted. EJB 3.0 specification has specified callbacks for which callback handler methods are to be created. EJB Container calls these callbacks. We can define callback methods in the ejb class itself or in a separate class. EJB 3.0 has provided many annotations for callbacks.
Q 2 - Which of the following is correct about @PostConstruct annotation for a callback method?
A - Method is invoked when a bean is created for the first time.
B - Method is invoked when a bean is removed from the bean pool or is destroyed.
Answer : A
Explaination
@PostConstruct - method is invoked when a bean is created for the first time.
Q 3 - Which of the following is correct about @PreDestroy annotation for a callback method?
A - Method is invoked when a bean is created for the first time.
B - Method is invoked when a bean is removed from the bean pool or is destroyed.
Answer : B
Explaination
@PreDestroy - method is invoked when a bean is removed from the bean pool or is destroyed.
Q 4 - Which of the following is correct about @PostActivate annotation for a callback method?
A - Method is invoked when a bean is created for the first time.
B - Method is invoked when a bean is removed from the bean pool or is destroyed.
Answer : C
Explaination
@PostActivate - method is invoked when a bean is loaded to be used.
Q 5 - Which of the following is correct about @PrePassivate annotation for a callback method?
A - Method is invoked when a bean is created for the first time.
B - Method is invoked when a bean is removed from the bean pool or is destroyed.
Answer : D
Explaination
@PrePassivate - method is invoked when a bean is put back to bean pool.
Q 6 - Which of the following is correct about @PrePersist annotation for a entity bean?
A - Method is invoked when an entity is created in database.
B - Method is invoked after an entity is created in database.
C - Method is invoked when an entity is deleted from the database.
D - Method is invoked after an entity is deleted from the database.
Answer : A
Explaination
@PrePersist - method is invoked when an entity is created in database.
Q 7 - Which of the following is correct about @PostPersist annotation for a entity bean?
A - Method is invoked when an entity is created in database.
B - Method is invoked after an entity is created in database.
C - Method is invoked when an entity is deleted from the database.
D - Method is invoked after an entity is deleted from the database.
Answer : B
Explaination
@PostPersist - method is invoked after an entity is created in database.
Q 8 - Which of the following is correct about @PreRemove annotation for a entity bean?
A - Method is invoked when an entity is created in database.
B - Method is invoked after an entity is created in database.
C - Method is invoked when an entity is deleted from the database.
D - Method is invoked after an entity is deleted from the database.
Answer : C
Explaination
@PreRemove - method is invoked when an entity is deleted from the database.
Q 9 - Which of the following is correct about @PostRemove annotation for a entity bean?
A - Method is invoked when an entity is created in database.
B - Method is invoked after an entity is created in database.
C - Method is invoked when an entity is deleted from the database.
D - Method is invoked after an entity is deleted from the database.
Answer : D
Explaination
@PostRemove - method is invoked after an entity is deleted from the database.
Q 10 - Which of the following is correct about @PreUpdate annotation for a entity bean?
A - Method is invoked before an entity is to be updated in the database.
B - Method is invoked after an entity is created in database.
C - Method is invoked when an entity is deleted from the database.
D - Method is invoked after an entity is deleted from the database.
Answer : A
Explaination
@PreUpdate - method is invoked before an entity is to be updated in the database.
Q 11 - Which of the following is correct about @PostLoad annotation for a entity bean?
A - Method is invoked before an entity is to be updated in the database.
B - Method is invoked when a record is fetched from database and loaded into the entity.
C - Method is invoked when an entity is deleted from the database.
D - Method is invoked after an entity is deleted from the database.
Answer : B
Explaination
@PostLoad - is invoked when a record is fetched from database and loaded into the entity.
Q 12 - Which of the following is correct about timer service in EJB?
A - Timer Service is a mechanism using which scheduled application can be build.
Answer : C
Explaination
Timer Service is a mechanism using which scheduled application can be build. This service is provided by Ejb container which helps to create timer and to schedule callback when timer expires.
Q 13 - Which annotation is used to inject an ejb into another ejb?
Answer : A
Explaination
@EJB annotation is used to inject other EJB reference.
Q 14 - Which annotation is used to inject an datasource into an ejb?
Answer : B
Explaination
@Resource annotation is used to inject an datasource into an ejb.
Q 15 - Which annotation is used to inject singleton services like timer service into an ejb?
Answer : B
Explaination
@Resource annotation is used to inject singleton services like timer service into an ejb.
Q 16 - Which annoatation is used to inject SessionContext into an ejb?
Answer : B
Explaination
@Resource annotation is used to inject SessionContext into an ejb.
Q 17 - Which of the following is correct about EJB interceptors?
B - An interceptor method is called by ejbContainer before business method call it is intercepting.
Answer : C
Explaination
EJB 3.0 provides specification to intercept business methods calls using methods annotated with @AroundInvoke annotation. An interceptor method is called by ejbContainer before business method call it is intercepting.
Q 18 - Which of the following is correct about Class level interceptor in EJB?
A - Such interceptor is invoked for every method of the bean.
B - Such interceptor is invoked for every bean within deployment.
C - Such interceptor is invoked for a particular method of the bean.
Answer : A
Explaination
Class level interceptor is invoked for every method of the bean.
Q 19 - Which of the following is correct about Default interceptor in EJB?
A - Such interceptor is invoked for every method of the bean.
B - Such interceptor is invoked for every bean within deployment.
C - Such interceptor is invoked for a particular method of the bean.
Answer : B
Explaination
Default interceptor is invoked for every bean within deployment.
Q 20 - Which of the following is correct about Method level interceptor in EJB?
A - Such interceptor is invoked for every method of the bean.
B - Such interceptor is invoked for every bean within deployment.
C - Such interceptor is invoked for a particular method of the bean.
Answer : C
Explaination
Method level interceptor is invoked for a particular method of the bean.
Q 21 - Which of the following is correct about @Embeddable annotation for a entity bean?
A - A java POJO to be embedded must be annotated as @Embeddable.
B - An entity bean to be embedded must be annotated as @Embeddable.
Answer : A
Explaination
A java POJO to be embedded must be annotated as @Embeddable.
Answer : A
Explaination
EJB 3.0 provides support for Blob and Clob types using @Lob annotation.
Q 23 - Which of the following types of java classes can be mapped using @Lob annotation?
Answer : C
Explaination
Both of the above classes can be mapped using @Lob annotation.
Q 24 - Which of the following types of java classes can be mapped using @Lob annotation?
Answer : D
Explaination
All of the above classes can be mapped using @Lob annotation.
Q 25 - Which of the following is correct about a transaction in EJB?
A - A transaction is a single unit of work items.
Answer : C
Explaination
A transaction is a single unit of work items which follows the ACID properties.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | D |
2 | A |
3 | B |
4 | C |
5 | D |
6 | A |
7 | B |
8 | C |
9 | D |
10 | A |
11 | B |
12 | C |
13 | A |
14 | B |
15 | B |
16 | B |
17 | C |
18 | A |
19 | B |
20 | C |
21 | A |
22 | A |
23 | C |
24 | D |
25 | C |
To Continue Learning Please Login
Login with Google