Hibernate Online Quiz


Advertisements

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

Explaination

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

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.

Q 3 - Session.createSQLQuery creates a new instance of Query for the given HQL query string.

A - true

B - false

Answer : B

Explaination

Session.createSQLQuery creates a new instance of Query for the given SQL query string.

Q 4 - Which of the following is the root node of hbm.xml file?

A - hibernate-mapping

B - hibernate-config

C - class-mapping

D - class-config

Answer : A

Explaination

The mapping document is an XML document having <b><hibernate-mapping></b> as the root element which contains all the <class> elements.

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 many-to-many relationship in hibernate?

A - <many-to-many>

B - <many-many>

C - <ManyToMany>

D - None of the above.

Answer : A

Explaination

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

Q 7 - Is second level caching mandatory in hibernate?

A - true

B - false

Answer : B

Explaination

Second level cache is an optional cache and first-level cache will always be consulted before any attempt is made to locate an object in the second-level cache.

Answer : C

Explaination

Nonstrict-read-write strategy makes no guarantee of consistency between the cache and the database. Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern.

Answer : A

Explaination

Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational Table mapping. All the metadata is clubbed into the POJO java file along with the code this helps the user to understand the table structure and POJO simultaneously during the development.

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