Advance Java MCQ Questions and Answers

Hibernate MCQ Questions and Answers

Some of the important Hibernate MCQ Questions and Answers are given below:

01. Which of the following database is not supported by Hibernate?

  1. FoundationDB
  2. MySQL
  3. PostgreSQL
  4. DB2/NT

Answer : A
Explanation: FoundationDB is a NoSQL database and is not supported by Hibernate and hence option A is correct.

02. The hibernate XML configuration file name is?

  1. hibernate.cfg.xml
  2. hibernate.cg.xml
  3. hibernate.config.xml
  4. None of the mentioned

Answer : A
Explanation: The hibernate XML configuration file name is hibernate.cfg.xml

03. Which of the following is not a core interface of Hibernate?

  1. Configuration
  2. Criteria
  3. SessionManagement
  4. Session

Answer : C
Explanation: SessionManagement is not a core interface of Hibernate but Configuration, Criteria, SessionFactory, Session, Query and Transaction are the core interfaces of Hibernate. So option C is correct.

04. Hibernate SessionFactory represent which level of cache?

  1. Second Level
  2. Third Level
  3. First Level
  4. Fourth Level

Answer : A
Explanation: Hibernate SessionFactory represent Second level of cache. So option A is correct.

05. While creating SessionFactory in hibernate, which design pattern should be adopted? 

  1. Prototype
  2. Singleton

Answer : B
Explanation: SessionFactory is built at the time of application startup and it follows the singleton design pattern. So option B is correct.

06. What is ORM?

  1. ORM is the automated persistence of objects in a Java application to the tables in a relational database
  2. ORM stands for object-relational mapping
  3. Both A & B
  4. None of the mentioned

Answer : C
Explanation: ORM is the automated persistence of objects in a Java application to the tables in a relational database as well as ORM stands for object-relational mapping. So both of them are correct.

07. What does the Session object hold?

  1. Second Level Cache
  2. First Level Cache
  3. Both A & B
  4. None of the mentioned

Answer : B
Explanation: The Session object holds first level cache. So answer B is correct.

08. In which file database table configuration is stored?

  1. .dbm
  2. .ora
  3. .sql
  4. .hbm

Answer : D
Explanation: Database table configuration is stored in a .hbm file.

09. Which method is used to save the state of the given instance from the underlying database?

  1. Session.load()
  2. Session.save()
  3. Session.store()
  4. Session.keep()

Answer : B
Explanation: Session.save is used to save the state of the given instance from the underlying database.

10.  Which element in hibernate maps java.util.SortedMap property ?

  1. < list >
  2. < set >
  3. < map >
  4. < tree >

Answer : C
Explanation: < map > in hibernate maps java.util.SortedMap property.

This Post Has 2 Comments

Leave a Reply