Spring Mock Test



This section presents you various set of Mock Tests related to Spring 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

Spring Mock Test IV

Q 1 - By default a bean is lazily loaded.

A - True

B - False

Answer : B

Explanation

By default a bean is eagerly loaded.

Q 2 - By default a bean is eagerly loaded.

A - False

B - True

Answer : B

Explanation

By default a bean is eagerly loaded.

Q 3 - If a bean is scoped to HTTP request, scope is

A - session

B - global-session

C - prototype

D - request

Answer : D

Explanation

If a bean is scoped to HTTP request, scope is request.

Q 4 - If a bean is created once per Ioc Container, scope is

A - singleton

B - global-session

C - prototype

D - request

Answer : A

Explanation

If a bean is created once per Ioc Container, scope is singleton.

Q 5 - Thread scoped bean is introduced in which version of spring framework.

A - 1.0

B - 2.0

C - 3.0

D - 4.0

Answer : C

Explanation

Thread scoped bean is introduced in 3.0 version of spring framework.

Q 6 - If a bean can be created any number of times, scope is

A - session

B - global-session

C - prototype

D - request

Answer : C

Explanation

In prototype scope, a bean can be created any number of times.

Q 7 - What is the scope of stateless bean?

A - global-session

B - singleton

C - prototype

D - request

Answer : B

Explanation

Stateless bean is of singleton scope.

Q 8 - What is the scope of stateful bean?

A - session

B - global-session

C - prototype

D - request

Answer : C

Explanation

Stateful bean is of prototype scope.

Q 9 - If a bean is scoped to HTTP session, scope is

A - global-session

B - session

C - prototype

D - request

Answer : B

Explanation

If a bean is scoped to HTTP session, scope is session.

Answer : D

Explanation

Using registerShutdownHook() method, shut down of IoC container can be handled. Other methods do not exists.

Answer : D

Explanation

Life cycle of a bean can be controlled using init() method or using InitializingBean / DisposableBean classes.

Q 12 - What is the scope of bean in portlet context?

A - session

B - global-session

C - prototype

D - request

Answer : B

Explanation

Scope of bean in portlet context is global-session.

Answer : A

Explanation

after advice runs after a method execution regardless of its outcome.

Q 14 - Which class is used to map a database row to a java object in spring?

A - ResultSet

B - RowMapper

C - RowSetMapper

D - ResultSetMapper

Answer : B

Explanation

RowMapper class is used to map a database row to a java object in spring.

Q 15

A bean must have id attribute in beans configuration file.

A - True

B - False

Answer : B

Explanation

Id is not a mandatory attribute in beans configuration file.

Q 16 - Which of the following class can be used to execute Sql queries in spring?

B - JDBCHelper

A - JdbcTemplate

C - DBHelper

D - DBTemplate

Answer : B

Explanation

JdbcTemplate class can be used to execute Sql queries in spring.

Q 17 - Which of the following class can be used to call Stored Procedures in spring?

A - SPHelper

B - JdbcTemplateCall

C - JdbcTemplate

D - SimpleJdbcCall

Answer : D

Explanation

SimpleJdbcCall class can be used to call Stored Procedures in spring.

Answer : C

Explanation

ACID stands for Atomicity, Consistency, Isolation, Durability.

Answer : B

Explanation

DispatcherServlet is defined in web.xml of web application.

Answer : B

Explanation

BeanPostProcessor is an interface.

Answer : B

Explanation

BeanPostProcessor defines callback methods that you can implement to provide your own instantiation logic, dependency-resolution logic etc.

Q 23 - Can be bean be configured to have an inner bean?

A - True

B - False

Answer : A

Explanation

A bean can be configured to have an inner bean.

Q 24 - Can we inject value and ref both together in a bean?

A - True

B - False

Answer : A

Explanation

Both values and ref can be injected at a time in a bean.

Q 25 - Following class can be extended to create custom event in spring.

A - SpringEvent

B - Event

C - ApplicationEvent

D - None of above

Answer : C

Explanation

ApplicationEvent is used to create custom events.

Answer Sheet

Question Number Answer Key
1 B
2 B
3 D
4 A
5 C
6 C
7 B
8 C
9 B
10 D
11 D
12 B
13 A
14 B
15 B
16 A
17 D
18 C
19 C
20 B
21 B
22 B
23 A
24 A
25 C
spring_questions_answers.htm
Advertisements