Hibernate Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to Hibernate Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - 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 2 - 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.

Q 3 - 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.

Q 4 - Which of the following elements is used to define specific mappings from a Java classes to the database tables?

A - property

B - hibernate-config

C - class

D - class-config

Answer : C

Explaination

The <class> elements are used to define specific mappings from a Java classes to the database tables. The Java class name is specified using the name attribute of the class element and the database table name is specified using the table attribute.

Q 5 - Which of the following element maps java.util.Set property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : A

Explaination

java.util.Set property is mapped with a <set> element and initialized with java.util.HashSet.

Q 6 - 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 : 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 8 - Which of the following database is not supported by Hibernate?

A - Oracle

B - Microsoft SQL Server Database

C - FoundationDB

D - Informix Dynamic Server

Answer : C

Explaination

FoundationDB is a NoSQL database and is not supported by Hibernate.

Q 9 - A Session is used to get a physical connection with a database.

A - true

B - false

Answer : A

Explaination

A Session is used to get a physical connection with a database.

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.

hibernate_questions_answers.htm
Advertisements