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

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

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

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 4 - Which element of hbm.xml defines maps the unique ID attribute in class to the primary key of the database table?

A - id

B - generator

C - primaryKey

D - None of the above.

Answer : A

Explaination

The <id> element maps the unique ID attribute in class to the primary key of the database table.

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

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : C

Explaination

java.util.Collection property is mapped with a <bag> or <ibag> element and initialized with java.util.ArrayList.

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 : A

Explaination

HQL stands for Hibernate Query Language.

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.

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.

Answer : A

Explaination

HQL supports INSERT INTO clause only where records can be inserted from one object to another object.

hibernate_questions_answers.htm
Advertisements