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 : 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 2 - Is Session a thread-safe object?

A - true

B - false

Answer : B

Explaination

No, Session is not thread-safe.

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

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.List property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : B

Explaination

java.util.List property is mapped with a <list> element and initialized with java.util.ArrayList.

Q 6 - Which of the following element is used to represent one-to-one relationship in hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above.

Answer : A

Explaination

<many-to-one> element is used to define one-to-one association.

Q 7 - Is first level caching mandatory in hibernate?

A - true

B - false

Answer : A

Explaination

The first-level cache is the Session cache and is a mandatory cache through which all requests must pass.

Answer : B

Explaination

Use Read-write strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.

Q 9 - Configuration object is used to create SessionFactory object in hibernate.

A - true

B - false

Answer : A

Explaination

Configuration object is used to create a SessionFactory object.

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.

hibernate_questions_answers.htm
Advertisements