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

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 3 - Session.createCriteria creates a new Criteria instance, for the given entity class, or a superclass of an entity class.

A - true

B - false

Answer : A

Explaination

Session.createCriteria creates a new Criteria instance, for the given entity class, or a superclass of an entity class.

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

A - <set>

B - <list>

C - <bag>

D - <map>

Answer : D

Explaination

java.util.Map property is mapped with a <map> element and initialized with java.util.HashMap.

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.

Answer : D

Explaination

HQL takes java objects in the same way as SQL takes tables. HQL is a Object Oriented Query language and is database independent.

Answer : D

Explaination

Query level cache is an optional feature and requires two additional physical cache regions that hold the cached query results and the timestamps when a table was last updated. This is only useful for queries that are run frequently with the same parameters.

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

By default, the @Id annotation will automatically determine the most appropriate primary key generation strategy to be used but you can override this by applying the @GeneratedValue annotation which takes two parameters strategy and generator.

hibernate_questions_answers.htm
Advertisements