- Hibernate Tutorial
- Hibernate - Home
- ORM - Overview
- Hibernate - Overview
- Hibernate - Architecture
- Hibernate - Environment
- Hibernate - Configuration
- Hibernate - Sessions
- Hibernate - Persistent Class
- Hibernate - Mapping Files
- Hibernate - Mapping Types
- Hibernate - Examples
- Hibernate - O/R Mappings
- Hibernate - Annotations
- Hibernate - Query Language
- Hibernate - Criteria Queries
- Hibernate - Native SQL
- Hibernate - Caching
- Hibernate - Batch Processing
- Hibernate - Interceptors
- Hibernate Useful Resources
- Hibernate - Questions and Answers
- Hibernate - Quick Guide
- Hibernate - Useful Resources
- Hibernate - Discussion
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.
Hibernate Mock Test III
Q 1 - Which of the following element is used to represent one-to-one relationship in hibernate?
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?
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?
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?
Answer : A
Explaination
<one-to-many> element is used to define one-to-many association.
Q 5 - Which of the following situation represents many-to-many relationship?
B - An employee can have multiple certificates.
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.
Q 6 - What is the difference between save() and persist() methods of session object?
B - save saves the object and returns status whereas persist stores status in different variable.
Answer : C
Explaination
save saves the object and returns the id of the instance whereas persist do not return anything after saving the instance.
Q 7 - What is the difference between get() and load() methods of session object?
B - get() always hits the database whereas load() method doesn't hit the database.
C - get() returns actual object whereas load() returns proxy object.
Answer : D
Explaination
All of the above are correct.
Q 8 - What is lazy loading?
A - Lazy loading is a technique in which objects are loaded on demand basis.
B - Lazy loading is a technique in which objects are persisted on demand basis.
Answer : A
Explaination
Lazy loading is a technique in which objects are loaded on demand basis.
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?
Answer : B
Explaination
In lazy loading child objects are not loaded when parent is loaded.
Q 11 - What HQL stands for?
Answer : A
Explaination
HQL stands for Hibernate Query Language.
Q 12 - Which of the following is true about HQL?
A - HQL takes java objects in the same way as SQL takes tables.
B - HQL is a Object Oriented 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.
Q 13 - What is first level cache in hibernate?
A - The first-level cache is the Session based cache.
B - The first-level cache is the SessionFactory based cache.
Answer : A
Explaination
The first-level cache is the Session cache and is a mandatory cache through which all requests must pass.
Q 14 - Whis of the following is true about first level cache in hibernate?
A - The first-level cache is the Session cache.
B - The first-level cache is a mandatory cache through which all requests must pass.
C - The Session object keeps an object under its own power before committing it to the database.
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.
Q 15 - What is second level cache in hibernate?
Answer : A
Explaination
The second-level cache is the SessionFactory based cache and is mainly responsible for caching objects across sessions.
Q 16 - Whis of the following is true about second level cache in hibernate?
A - The second-level cache is the SessionFactory based cache.
B - The second-level cache can be configured on a per-class and per-collection basis.
C - The second-level cache 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.
Answer : A
Explaination
The first-level cache is the Session cache and is a mandatory cache through which all requests must pass.
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.
Answer : B
Explaination
query level cache is an optional cache.
Q 20 - What is Query level cache in hibernate?
Answer : A
Explaination
Hibernate implements a cache for query resultsets that integrates closely with the second-level cache.
Q 21 - Which of the following is true about query level cache in hibernate?
A - Query level cache is an optional feature.
C - Query level cache is only useful for queries that are run frequently with the same parameters.
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?
Answer : D
Explaination
All of the above are concurrency strategies in hibernate.
Q 23 - When a Transactional concurrency strategy is to be used?
Answer : B
Explaination
Use Transactional strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.
Q 24 - When a Read-write concurrency strategy is to be used?
Answer : B
Explaination
Use Read-write strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.
Q 25 - When a Nonstrict-read-write concurrency strategy is to be used?
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 |