Hibernate MCQ

This set of Java Multiple Choice Questions & Answers (MCQs) focuses on “Hibernate”.

1. Which of the following is not a core interface of Hibernate?
a) Configuration
b) Criteria
c) SessionManagement
d) Session
View Answer

Answer: c
Explanation: SessionManagement is not a core interface of Hibernate. Configuration, Criteria, SessionFactory, Session, Query and Transaction are the core interfaces of Hibernate.

2. SessionFactory is a thread-safe object.
a) True
b) False
View Answer

Answer: a
Explanation: SessionFactory is a thread-safe object. Multiple threads can access it simultaneously.

3. Which of the following methods returns proxy object?
a) loadDatabase()
b) getDatabase()
c) load()
d) get()
View Answer

Answer: c
Explanation: load() method returns proxy object. load() method should be used if it is sure that instance exists.
advertisement
advertisement

4. Which of the following methods hits database always?
a) load()
b) loadDatabase()
c) getDatabase()
d) get()
View Answer

Answer: d
Explanation: get() method hits database always. Also, get() method does not return proxy object.

5. Which of the following method is used inside session only?
a) merge()
b) update()
c) end()
d) kill()
View Answer

Answer: b
Explanation: update() method can only be used inside session. update() should be used if session does not contain persistent object.

6. Which of the following is not a state of object in Hibernate?
a) Attached()
b) Detached()
c) Persistent()
d) Transient()
View Answer

Answer: a
Explanation: Attached() is not a state of object in Hibernate. Detached(), Persistent() and Transient() are the only states in Hibernate.

7. Which of the following is not an inheritance mapping strategies?
a) Table per hierarchy
b) Table per concrete class
c) Table per subclass
d) Table per class
View Answer

Answer: d
Explanation: Table per class is not an inheritance mapping strategies.
advertisement

8. Which of the following is not an advantage of using Hibernate Query Language?
a) Database independent
b) Easy to write query
c) No need to learn SQL
d) Difficult to implement
View Answer

Answer: d
Explanation: HQL is easy to implement. Also, to implement it HQL it is not dependent on a database platform.

9. In which file database table configuration is stored?
a) .dbm
b) .hbm
c) .ora
d) .sql
View Answer

Answer: b
Explanation: Database table configuration is stored in .hbm file.
advertisement

10. Which of the following is not an advantage of Hibernate Criteria API?
a) Allows to use aggregate functions
b) Cannot order the result set
c) Allows to fetch only selected columns of result
d) Can add conditions while fetching results
View Answer

Answer: b
Explanation: addOrder() can be used for ordering the results.

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.