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
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
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
Explanation: load() method returns proxy object. load() method should be used if it is sure that instance exists.
4. Which of the following methods hits database always?
a) load()
b) loadDatabase()
c) getDatabase()
d) get()
View Answer
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
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
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
Explanation: Table per class is not an inheritance mapping strategies.
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
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
Explanation: Database table configuration is stored in .hbm file.
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
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.
- Practice Programming MCQs
- Check Java Books
- Apply for Computer Science Internship
- Practice Information Technology MCQs
- Apply for Java Internship