- 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
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 I
Q 1 - What JDBC stands for?
Answer : B
Explaination
JDBC stands for Java Database Connectivity and provides a set of Java API for accessing the relational databases from Java program.
Q 2 - Which of the following is true about JDBC?
A - JDBC stands for Java Database Connectivity.
B - JDBC provides a set of Java API for accessing the relational databases from Java program.
Answer : D
Explaination
JDBC stands for Java Database Connectivity and provides a set of Java API for accessing the relational databases from Java program. These Java APIs enables Java programs to execute SQL statements and interact with any SQL compliant database.
Q 3 - What ORM stands for?
Answer : B
Explaination
ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data between relational databases.
Q 4 - Which of the following is true about ORM?
A - ORM stands for Object-Relational Mapping.
B - ORM is a programming technique for converting data between relational databases.
Answer : C
Explaination
ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data between relational databases.
Q 5 - Which of the following is not an ORM framework?
Answer : D
Explaination
NoSQL is not an ORM framework.
Q 6 - Which of the following is true about Hibernate?
A - Hibernate is an Object-Relational Mapping(ORM) solution for JAVA.
B - Hibernate is an Object-Relational Mapping(ORM) solution for .NET
Answer : A
Explaination
Hibernate is an Object-Relational Mapping(ORM) solution for JAVA.
Q 7 - Which of the following is true about Hibernate?
Answer : D
Explaination
All of the above options are true about Hibernate.
Q 8 - 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 9 - Which of the following tools/frameworks provides integration with Hibernate?
Answer : D
Explaination
All of the above provide integration with Hibernate.
Q 10 - Which of the following is not a core component of Hibernate?
Answer : A
Explaination
JDBC is not a core component of Hibernate.
Q 11 - Which of the following is not a core component of Hibernate?
Answer : B
Explaination
Provider is not a core component of Hibernate.
Q 12 - Which of the following is true about configuration component of Hibernate?
A - The Configuration object is the first Hibernate object you create in any Hibernate application.
B - The Configuration object is usually created only once during application initialization.
Answer : D
Explaination
The Configuration object is the first Hibernate object you create in any Hibernate application and usually created only once during application initialization. It represents a configuration or properties file required by the Hibernate.
Q 13 - Which of the following object is used to create SessionFactory object in hibernate?
Answer : A
Explaination
Configuration object is used to create a SessionFactory object.
Q 14 - Which of the following is true about SessionFactory object in hibernate?
B - SessionFactory object allows for a Session object to be instantiated.
Answer : D
Explaination
SessionFactory object configures Hibernate for the application using the supplied configuration file and allows for a Session object to be instantiated. The SessionFactory is a thread safe object and used by all the threads of an application.
Q 15 - Which of the following is true about SessionFactory object in hibernate?
A - The SessionFactory is heavyweight object.
B - SessionFactory object is created during application start up and kept for later use.
C - You would need one SessionFactory object per database using a separate configuration file.
Answer : D
Explaination
The SessionFactory is heavyweight object so usually it is created during application start up and kept for later use. You would need one SessionFactory object per database using a separate configuration file. So if you are using multiple databases then you would have to create multiple SessionFactory objects.
Q 16 - Which of the following is true about Session object in hibernate?
A - A Session is used to get a physical connection with a database.
B - The Session object is lightweight.
C - Persistent objects are saved and retrieved through a Session object.
Answer : D
Explaination
A Session is used to get a physical connection with a database. The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database. Persistent objects are saved and retrieved through a Session object.
Answer : A
Explaination
Yes, SessionFactory is a thread-safe and can be accessed by multiple threads simultaneously.
Answer : B
Explaination
No, Session is not thread-safe.
Q 19 - Which of the following is true about Transaction object in hibernate?
A - A Transaction represents a unit of work with the database.
B - Transactions in Hibernate are handled by an underlying transaction manager.
Answer : D
Explaination
A Transaction represents a unit of work with the database and most of the RDBMS supports transaction functionality. Transactions in Hibernate are handled by an underlying transaction manager and transaction (from JDBC or JTA).This is an optional object and Hibernate applications may choose not to use this interface, instead managing transactions in their own application code.
Q 20 - Which of the following is true about Query object in hibernate?
B - Query objects SQL string to retrieve data from the database and create objects.
Answer : D
Explaination
Query objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects. A Query instance is used to bind query parameters, limit the number of results returned by the query, and finally to execute the query.
Q 21 - Which of the following is true about hibernate.dialect property in hibernate configuration?
A - This property makes Hibernate generate the appropriate SQL for the chosen database.
B - This property makes Hibernate generate the appropriate java code for the chosen database.
Answer : A
Explaination
This property makes Hibernate generate the appropriate SQL for the chosen database.
Q 22 - Which of the following is true about transient state of a persistent entity?
A - A new instance of a persistent class which is not associated with a Session.
B - A new instance of a persistent class which has no representation in the database.
C - A new instance of a persistent class which has no identifier value.
Answer : D
Explaination
A new instance of a a persistent class which is not associated with a Session and has no representation in the database and no identifier value is considered transient by Hibernate.
Q 23 - Which of the following is true about persistent state of a persistent entity?
A - You can make a transient instance persistent by associating it with a Session.
B - A persistent instance has a representation in the database.
Answer : D
Explaination
You can make a transient instance persistent by associating it with a Session. A persistent instance has a representation in the database, an identifier value and is associated with a Session.
Q 24 - Which of the following is true about detached state of a persistent entity?
A - Once we close the Hibernate Session, the persistent instance will become a detached instance.
B - A new instance of a persistent class which is not associated with a Session.
C - You can make a transient instance detached by associating it with a Session.
Answer : A
Explaination
Once we close the Hibernate Session, the persistent instance will become a detached instance.
Q 25 - Session.beginTransaction method begins a unit of work and returns the associated Transaction object.
Answer : A
Explaination
Session.beginTransaction method begins a unit of work and returns the associated Transaction object.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | B |
2 | D |
3 | B |
4 | C |
5 | D |
6 | A |
7 | D |
8 | C |
9 | D |
10 | A |
11 | B |
12 | D |
13 | A |
14 | D |
15 | D |
16 | D |
17 | A |
18 | B |
19 | D |
20 | D |
21 | A |
22 | D |
23 | D |
24 | A |
25 | A |