Hibernate Mock Test



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

Hibernate Mock Test III

Q 1 - Which of the following element is used to represent one-to-one relationship in hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above.

Answer : A

Explaination

<many-to-one> element is used to define one-to-one association.

Q 2 - Which of the following element is used to represent one-to-many relationship in hibernate?

A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

Answer : A

Explaination

<one-to-many> element is used to define one-to-many association.

Q 3 - Which of the following element is used to represent many-to-many relationship in hibernate?

A - <many-to-many>

B - <many-many>

C - <ManyToMany>

D - None of the above.

Answer : A

Explaination

<many-to-many> element is used to define many-to-many association.

Q 4 - Which of the following element is used to represent one-to-many relationship in hibernate?

A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

Answer : A

Explaination

<one-to-many> element is used to define one-to-many association.

Answer : A

Explaination

An employee can have multiple certificates and same certificate can be conferred to many employees. Such situation represents many-to-many association.

Answer : C

Explaination

save saves the object and returns the id of the instance whereas persist do not return anything after saving the instance.

Answer : A

Explaination

Lazy loading is a technique in which objects are loaded on demand basis.

Q 9 - What is value of lazy loading by default?

A - true

B - false

Answer : A

Explaination

Since Hibernate 3, lazy loading is by default, enabled so that child objects are not loaded when parent is loaded.

Q 10 - Child objects are not loaded when parent is loaded/populated from database. What this technique is called?

A - Eager Loading

B - Lazy Loading

C - Request based Loading

D - None of the above.

Answer : B

Explaination

In lazy loading child objects are not loaded when parent is loaded.

Answer : A

Explaination

HQL stands for Hibernate Query Language.

Answer : D

Explaination

HQL takes java objects in the same way as SQL takes tables. HQL is a Object Oriented Query language and is database independent.

Answer : A

Explaination

The first-level cache is the Session cache and is a mandatory cache through which all requests must pass.

Answer : D

Explaination

The first-level cache is the Session cache and is a mandatory cache through which all requests must pass. The Session object keeps an object under its own power before committing it to the database.

Answer : A

Explaination

The second-level cache is the SessionFactory based cache and is mainly responsible for caching objects across sessions.

Answer : D

Explaination

Second level cache is an optional cache and first-level cache will always be consulted before any attempt is made to locate an object in the second-level cache. The second-level cache can be configured on a per-class and per-collection basis and mainly responsible for caching objects across sessions.

Q 17 - Is first level caching mandatory in hibernate?

A - true

B - false

Answer : A

Explaination

The first-level cache is the Session cache and is a mandatory cache through which all requests must pass.

Q 18 - Is second level caching mandatory in hibernate?

A - true

B - false

Answer : B

Explaination

Second level cache is an optional cache and first-level cache will always be consulted before any attempt is made to locate an object in the second-level cache.

Q 19 - Is query level caching mandatory in hibernate?

A - true

B - false

Answer : B

Explaination

query level cache is an optional cache.

Answer : A

Explaination

Hibernate implements a cache for query resultsets that integrates closely with the second-level cache.

Answer : D

Explaination

Query level cache is an optional feature and requires two additional physical cache regions that hold the cached query results and the timestamps when a table was last updated. This is only useful for queries that are run frequently with the same parameters.

Q 22 - Which of the following is a concurrency strategies in hibernate?

A - Transactional

B - Read-write

C - Nonstrict-read-write.

D - All of the above.

Answer : D

Explaination

All of the above are concurrency strategies in hibernate.

Answer : B

Explaination

Use Transactional strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.

Answer : B

Explaination

Use Read-write strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.

Answer : C

Explaination

Nonstrict-read-write strategy makes no guarantee of consistency between the cache and the database. Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern.

Answer Sheet

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