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.

Questions and Answers

EJB Mock Test III

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.

Answer : A

Explaination

@PostConstruct - method is invoked when a bean is created for the first time.

Answer : B

Explaination

@PreDestroy - 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.

Answer : D

Explaination

@PrePassivate - method is invoked when a bean is put back to bean pool.

Answer : A

Explaination

@PrePersist - method is invoked when an entity is created in database.

Answer : B

Explaination

@PostPersist - method is invoked after an entity is created in database.

Answer : C

Explaination

@PreRemove - method is invoked when an entity is deleted from the database.

Answer : D

Explaination

@PostRemove - 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.

Answer : B

Explaination

@PostLoad - is invoked when a record is fetched from database and loaded into the entity.

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?

A - @EJB

B - @Resource

C - Both of the above.

D - None of the above.

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?

A - @EJB

B - @Resource

C - Both of the above.

D - None of the above.

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?

A - @EJB

B - @Resource

C - Both of the above.

D - None of the above.

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?

A - @EJB

B - @Resource

C - Both of the above.

D - None of the above.

Answer : B

Explaination

@Resource annotation is used to inject SessionContext into an ejb.

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.

Answer : A

Explaination

Class level interceptor is invoked for every method of the bean.

Answer : B

Explaination

Default interceptor is invoked for every bean within deployment.

Answer : C

Explaination

Method level interceptor is invoked for a particular method of the bean.

Answer : A

Explaination

A java POJO to be embedded must be annotated as @Embeddable.

Q 22 - EJB 3.0 provides support for Blob and Clob types using @Lob annotation.

A - true

B - false

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?

A - java.sql.Blob

B - java.sql.Clob

C - Both of the above.

D - None of the above.

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?

A - byte[]

B - String

C - Serializable Object

D - All of the above.

Answer : D

Explaination

All of the above classes can be mapped using @Lob annotation.

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
ejb_questions_answers.htm
Advertisements