- 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 IV
Q 1 - When a Read-only concurrency strategy is to be used?
Answer : C
Explaination
Read-only concurrency strategy is suitable for data which never changes. Use it for reference data only.
Q 2 - Which of the following is true with respect to ORM vs JDBC?
A - ORM system lets business code access objects rather than DB tables.
B - ORM system hides details of SQL queries from OO logic.
C - ORM system helps in Transaction management and automatic key generation.
Answer : D
Explaination
All of the above are true with respect to ORM vs JDBC.
Q 3 - Which of the following is true about hibernate?
A - Hibernate does not require an application server to operate.
B - Hibernate manipulates Complex associations of objects of your database.
C - Hibernate minimize database access with smart fetching strategies.
Answer : D
Explaination
All of the above are true with respect to hibernate.
Q 4 - Which of the following database is not supported by Hibernate?
Answer : C
Explaination
FoundationDB is a NoSQL database and is not supported by Hibernate.
Q 5 - Which of the following database is supported by Hibernate?
Answer : D
Explaination
All of the above mentioned databases are supported by Hibernate.
Q 6 - Which of the following is a core component of Hibernate?
Answer : D
Explaination
All of the above mentioned are core component of Hibernate.
Answer : A
Explaination
Configuration object is used to create a SessionFactory object.
Answer : B
Explaination
The SessionFactory is heavyweight object so usually it is created during application start up and kept for later use.
Q 9 - You would need one SessionFactory object per database using a separate configuration file.
Answer : B
Explaination
You would need one SessionFactory object per database using a separate configuration file.
Answer : A
Explaination
A Session is used to get a physical connection with a database.
Answer : B
Explaination
The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database.
Answer : B
Explaination
Persistent objects are saved and retrieved through a Session object.
Q 13 - Which of the following is true about hibernate annotations?
Answer : A
Explaination
Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational Table mapping. All the metadata is clubbed into the POJO java file along with the code this helps the user to understand the table structure and POJO simultaneously during the development.
Q 14 - Which of the following is true about @Id annotation?
A - Hibernate detects that the @Id annotation is on a field.
Answer : C
Explaination
Hibernate detects that the @Id annotation is on a field and assumes that it should access properties on an object directly through fields at runtime.
Q 15 - Which of the following is true about @Entity annotation?
Answer : C
Explaination
@Entity annotation marks a class as an entity bean, so it must have a no-argument constructor that is visible with at least protected scope.
Q 16 - Which of the following is true about @Table annotation?
Answer : C
Explaination
The @Table annotation allows you to specify the details of the table that will be used to persist the entity in the database. The @Table annotation provides four attributes, allowing you to override the name of the table, its catalogue, and its schema, and enforce unique constraints on columns in the table.
Q 17 - Which of the following is true about @GeneratedValue annotation?
A - @GeneratedValue annotation takes two parameters strategy and generator.
B - @GeneratedValue annotation provides the primary key generation strategy to be used.
Answer : C
Explaination
By default, the @Id annotation will automatically determine the most appropriate primary key generation strategy to be used but you can override this by applying the @GeneratedValue annotation which takes two parameters strategy and generator.
Q 18 - Which of the following is true about @Column annotation?
Answer : A
Explaination
The @Column annotation is used to specify the details of the column to which a field or property will be mapped.
Q 19 - name attribute of @Column annotation permits the name of the column to be explicitly specified.
Answer : A
Explaination
name attribute of @Column annotation permits the name of the column to be explicitly specified.
Q 20 - length attribute of @Column annotation permits the size of the column used to map a value particularly for a String value.
Answer : B
Explaination
length attribute of @Column annotation permits the size of the column used to map a value particularly for a String value.
Q 21 - nullable attribute of @Column annotation permits the column to be marked NOT NULL when the schema is generated.
Answer : A
Explaination
nullable attribute of @Column annotation permits the column to be marked NOT NULL when the schema is generated.
Q 22 - Which of the following is true about HQL?
A - Hibernate Query Language (HQL) is an object-oriented query language.
Answer : C
Explaination
Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but instead of operating on tables and columns, HQL works with persistent objects and their properties.
Q 23 - Which of the following is true about HQL?
B - The AS clause can be used to assign aliases to the classes in HQL queries.
Answer : C
Explaination
HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action on database. The AS clause can be used to assign aliases to the classes in your HQL queries.
Q 24 - Which of the following is true about HQL?
A - Hibernate supports named parameters in its HQL queries.
B - HQL supports a range of aggregate methods, similar to SQL.
Answer : C
Explaination
Hibernate supports named parameters in its HQL queries. HQL supports a range of aggregate methods, similar to SQL.
Q 25 - Which of the following is true about INSERT CLAUSE in HQL?
B - HQL supports INSERT INTO clause without any restriction.
Answer : A
Explaination
HQL supports INSERT INTO clause only where records can be inserted from one object to another object.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | C |
2 | D |
3 | D |
4 | C |
5 | D |
6 | D |
7 | A |
8 | B |
9 | B |
10 | A |
11 | B |
12 | B |
13 | A |
14 | C |
15 | C |
16 | C |
17 | C |
18 | A |
19 | A |
20 | B |
21 | A |
22 | C |
23 | C |
24 | C |
25 | A |