Hibernate Mock Test


Advertisements


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 I

Answer : B

Explaination

JDBC stands for Java Database Connectivity and 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.

Answer : B

Explaination

ORM stands for Object-Relational Mapping (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?

A - Castor

B - Spring DAO

C - Hibernate

D - NoSQL

Answer : D

Explaination

NoSQL is not an ORM framework.

Answer : A

Explaination

Hibernate is an Object-Relational Mapping(ORM) solution for JAVA.

Q 8 - Which of the following database is not supported by Hibernate?

A - DB2/NT

B - MySQL

C - FoundationDB

D - PostgreSQL

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?

A - XDoclet Spring

B - J2EE

C - Maven

D - All of the above.

Answer : D

Explaination

All of the above provide integration with Hibernate.

Q 10 - Which of the following is not a core component of Hibernate?

A - JDBC

B - SessionFactory

C - Session

D - Configuration

Answer : A

Explaination

JDBC is not a core component of Hibernate.

Q 11 - Which of the following is not a core component of Hibernate?

A - Transaction

B - Provider

C - Criteria

D - Query

Answer : B

Explaination

Provider is not a core component of Hibernate.

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?

A - Configuration

B - Session

C - SessionFactory

D - Transaction

Answer : A

Explaination

Configuration object is used to create a SessionFactory object.

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.

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.

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.

Q 17 - Is SessionFactory a thread-safe object?

A - true

B - false

Answer : A

Explaination

Yes, SessionFactory is a thread-safe and can be accessed by multiple threads simultaneously.

Q 18 - Is Session a thread-safe object?

A - true

B - false

Answer : B

Explaination

No, Session is not thread-safe.

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.

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.

Answer : A

Explaination

This property makes Hibernate generate the appropriate SQL for the chosen database.

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.

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.

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.

A - true

B - false

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

hibernate_questions_answers.htm

Advertisements
E-Books Store