Hibernate Mock Test



This section presents you various set of Mock Tests related to Hibernate Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Hibernate Mock Test IV

Answer : C

Explaination

Read-only concurrency strategy is suitable for data which never changes. Use it for reference data only.

Answer : D

Explaination

All of the above are true with respect to ORM vs JDBC.

Q 4 - Which of the following database is not supported by Hibernate?

A - Oracle

B - Microsoft SQL Server Database

C - FoundationDB

D - Informix Dynamic Server

Answer : C

Explaination

FoundationDB is a NoSQL database and is not supported by Hibernate.

Q 5 - Which of the following database is supported by Hibernate?

A - DB2/NT

B - PostgreSQL

C - Sybase SQL Server

D - All of the above

Answer : D

Explaination

All of the above mentioned databases are supported by Hibernate.

Q 6 - Which of the following is a core component of Hibernate?

A - Transaction

B - SessionFactory

C - Session

D - All of the above

Answer : D

Explaination

All of the above mentioned are core component of Hibernate.

Q 7 - Configuration object is used to create SessionFactory object in hibernate.

A - true

B - false

Answer : A

Explaination

Configuration object is used to create a SessionFactory object.

Q 8 - The SessionFactory is heavyweight object.

A - false

B - true

Answer : B

Explaination

The SessionFactory is heavyweight object so usually it is created during application start up and kept for later use.

Q 9 - You would need one SessionFactory object per database using a separate configuration file.

A - false

B - true

Answer : B

Explaination

You would need one SessionFactory object per database using a separate configuration file.

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

Q 11 - The Session object is lightweight.

A - false

B - true

Answer : B

Explaination

The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database.

Q 12 - Persistent objects are saved and retrieved through a Session object.

A - false

B - true

Answer : B

Explaination

Persistent objects are saved and retrieved through a Session object.

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

Explaination

Hibernate detects that the @Id annotation is on a field and assumes that it should access properties on an object directly through fields at runtime.

Answer : C

Explaination

@Entity annotation marks a class as an entity bean, so it must have a no-argument constructor that is visible with at least protected scope.

Answer : C

Explaination

The @Table annotation allows you to specify the details of the table that will be used to persist the entity in the database. The @Table annotation provides four attributes, allowing you to override the name of the table, its catalogue, and its schema, and enforce unique constraints on columns in the table.

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.

Answer : A

Explaination

The @Column annotation is used to specify the details of the column to which a field or property will be mapped.

Q 19 - name attribute of @Column annotation permits the name of the column to be explicitly specified.

A - true

B - false

Answer : A

Explaination

name attribute of @Column annotation permits the name of the column to be explicitly specified.

Q 20 - length attribute of @Column annotation permits the size of the column used to map a value particularly for a String value.

A - false

B - true

Answer : B

Explaination

length attribute of @Column annotation permits the size of the column used to map a value particularly for a String value.

Q 21 - nullable attribute of @Column annotation permits the column to be marked NOT NULL when the schema is generated.

A - true

B - false

Answer : A

Explaination

nullable attribute of @Column annotation permits the column to be marked NOT NULL when the schema is generated.

Answer : C

Explaination

Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but instead of operating on tables and columns, HQL works with persistent objects and their properties.

Answer : C

Explaination

HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action on database. The AS clause can be used to assign aliases to the classes in your HQL queries.

Answer : C

Explaination

Hibernate supports named parameters in its HQL queries. HQL supports a range of aggregate methods, similar to SQL.

Answer : A

Explaination

HQL supports INSERT INTO clause only where records can be inserted from one object to another object.

Answer Sheet

Question Number Answer Key
1 C
2 D
3 D
4 C
5 D
6 D
7 A
8 B
9 B
10 A
11 B
12 B
13 A
14 C
15 C
16 C
17 C
18 A
19 A
20 B
21 A
22 C
23 C
24 C
25 A
hibernate_questions_answers.htm
Advertisements