0% found this document useful (0 votes)
253 views

Spring MVC Final

Cts Spring mvc dumps

Uploaded by

Jay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
253 views

Spring MVC Final

Cts Spring mvc dumps

Uploaded by

Jay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 357

HIBERNATE MOCK TEST

http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST I

Q 1 - What JDBC stands for?

A - Java DB Connectivity

B - Java Database Connectivity

C - Java Data Bind Connect

D - Java Data Bind Connector

Q 2 - Which of the following is true about JDBC?

A - JDBC stands for Java Database Connectivity.

B - JDBC provides a set of Java API for accessing the relational databases from Java program.

C - JDBC APIs enables Java programs to execute SQL statements and interact with any SQL
compliant database.

D - All of the above.

Q 3 - What ORM stands for?

A - Object Relation Map

B - Object Relational Mapping

C - Object Record Mapping

D - None of the above.

Q 4 - Which of the following is true about ORM?

A - ORM stands for Object-Relational Mapping.


B - ORM is a programming technique for converting data between relational databases.

C - Both of the above.

D - None of the above.

Q 5 - Which of the following is not an ORM framework?

A - Castor

B - Spring DAO

C - Hibernate

D - NoSQL

Q 6 - Which of the following is true about Hibernate?

A - Hibernate is an Object-Relational MappingORM solution for JAVA.

B - Hibernate is an Object-Relational MappingORM solution for .NET

C - Both of the above.

D - None of the above.

Q 7 - Which of the following is true about Hibernate?

A - Hibernate takes care of mapping Java classes to database tables using XML files and without
writing any line of code.

B - Hibernate provides simple APIs for storing and retrieving Java objects directly to and from the
database.

C - Hibernate abstracts away the unfamiliar SQL types and provide us to work around familiar
Java Objects.

D - All of the above.

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

A - DB2/NT

B - MySQL

C - FoundationDB

D - PostgreSQL

Q 9 - Which of the following tools/frameworks provides integration with Hibernate?

A - XDoclet Spring

B - J2EE

C - Maven

D - All of the above.


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

A - JDBC

B - SessionFactory

C - Session

D - Configuration

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

A - Transaction

B - Provider

C - Criteria

D - Query

Q 12 - Which of the following is true about configuration component of Hibernate?

A - The Configuration object is the first Hibernate object you create in any Hibernate application.

B - The Configuration object is usually created only once during application initialization.

C - The Configuration object represents a configuration or properties file required by the


Hibernate.

D - All of the above.

Q 13 - Which of the following object is used to create SessionFactory object in


hibernate?

A - Configuration

B - Session

C - SessionFactory

D - Transaction

Q 14 - Which of the following is true about SessionFactory object in hibernate?

A - SessionFactory object configures Hibernate for the application using the supplied
configuration file.

B - SessionFactory object allows for a Session object to be instantiated.

C - The SessionFactory is a thread safe object.

D - All of the above.

Q 15 - Which of the following is true about SessionFactory object in hibernate?

A - The SessionFactory is heavyweight object.


B - SessionFactory object is created during application start up and kept for later use.

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

D - All of the above.

Q 16 - Which of the following is true about Session object in hibernate?

A - A Session is used to get a physical connection with a database.

B - The Session object is lightweight.

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

D - All of the above.

Q 17 - Is SessionFactory a thread-safe object?

A - true

B - false

Q 18 - Is Session a thread-safe object?

A - true

B - false

Q 19 - Which of the following is true about Transaction object in hibernate?

A - A Transaction represents a unit of work with the database.

B - Transactions in Hibernate are handled by an underlying transaction manager.

C - This is an optional object and Hibernate applications may choose not to use this interface,
instead managing transactions in their own application code.

D - All of the above.

Q 20 - Which of the following is true about Query object in hibernate?

A - Query objects Hibernate Query Language HQL string to retrieve data from the database and
create objects.

B - Query objects SQL string to retrieve data from the database and create objects.

C - A Query instance is used to bind query parameters, limit the number of results returned by
the query, and finally to execute the query.

D - All of the above.

Q 21 - Which of the following is true about hibernate.dialect property in hibernate


configuration?

A - This property makes Hibernate generate the appropriate SQL for the chosen database.

B - This property makes Hibernate generate the appropriate java code for the chosen database.
C - Both of the above.

D - None of the above.

Q 22 - Which of the following is true about transient state of a persistent entity?

A - A new instance of a persistent class which is not associated with a Session.

B - A new instance of a persistent class which has no representation in the database.

C - A new instance of a persistent class which has no identifier value.

D - All of the above.

Q 23 - Which of the following is true about persistent state of a persistent entity?

A - You can make a transient instance persistent by associating it with a Session.

B - A persistent instance has a representation in the database.

C - A persistent instance has an identifier value.

D - All of the above.

Q 24 - Which of the following is true about detached state of a persistent entity?

A - Once we close the Hibernate Session, the persistent instance will become a detached
instance.

B - A new instance of a persistent class which is not associated with a Session.

C - You can make a transient instance detached by associating it with a Session.

D - None of the above.

Q 25 - Session.beginTransaction method begins a unit of work and returns the


associated Transaction object.

A - true

B - false

ANSWER SHEET

Question Number Answer Key

1 B

2 D

3 B

4 C

5 D

6 A
7 D

8 C

9 D

10 A

11 B

12 D

13 A

14 D

15 D

16 D

17 A

18 B

19 D

20 D

21 A

22 D

23 D

24 A

25 A

Loading [MathJax]/jax/output/HTML-CSS/jax.js
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST II

Q 1 - Session.createCriteria creates a new Criteria instance, for the given entity class,
or a superclass of an entity class.

A - true

B - false

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

A - true

B - false

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

A - true

B - false

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

A - true

B - false

Q 5 - Which method is used to remove a persistent instance from the datastore?

A - Session.delete

B - Session.remove
C - Session.del

D - Session.rm

Q 6 - Which method is used to get a persistent instance from the datastore?

A - Session.read

B - Session.get

C - Session.retrieve

D - Session.fetch

Q 7 - Which method is used to re-read the state of the given instance from the
underlying database?

A - Session.refresh

B - Session.get

C - Session.reload

D - Session.retrieve

Q 8 - Which method is used to save the state of the given instance from the
underlying database?

A - Session.store

B - Session.keep

C - Session.save

D - Session.load

Q 9 - Which method is used to update the state of the given instance from the
underlying database?

A - Session.store

B - Session.keep

C - Session.update

D - Session.load

Q 10 - Which method is used to save or update the state of the given instance from
the underlying database?

A - Session.saveOrUpdate

B - Session.keep

C - Session.update

D - Session.load
Q 11 - Which of the following is the root node of hbm.xml file?

A - hibernate-mapping

B - hibernate-config

C - class-mapping

D - class-config

Q 12 - Which of the following elements is used to define specific mappings from a Java
classes to the database tables?

A - property

B - hibernate-config

C - class

D - class-config

Q 13 - Which of the following is true about <class> element?

A - The <class> elements are used to define specific mappings from a Java classes to the
database tables.

B - The Java class name is specified using the name attribute of the class element.

C - The database table name is specified using the table attribute of the class element.

D - All of the above.

Q 14 - Which element of hbm.xml defines maps the unique ID attribute in class to the
primary key of the database table?

A - id

B - generator

C - primaryKey

D - None of the above.

Q 15 - Which of the following is true about <id> element?

A - The <id> element maps the unique ID attribute in class to the primary key of the database
table.

B - The name attribute of the id element refers to the property in the class.

C - The column attribute of the id element refers to the column in the database table.

D - All of the above.

Q 16 - Which element of hbm.xml automatically generate the primary key values?

A - id
B - generator

C - primaryKey

D - None of the above.

Q 17 - Which of the following is true about <generator> element?

A - The <generator> element within the id element is used to automatically generate the
primary key values

B - Set the class attribute of the generator element is set to native to let hibernate pick up either
identity, sequence or hilo algorithm to create primary key depending upon the capabilities of the
underlying database.

C - Both of the above.

D - None of the above.

Q 18 - Which element of hbm.xml is used to map a Java class property to a column in


the database table?

A - id

B - generator

C - property

D - class

Q 19 - Which of the following is true about <property> element?

A - The <property> element is used to map a Java class property to a column in the database
table.

B - The name attribute of the element refers to the property in the class.

C - The column attribute of the element refers to the column in the database table.

D - All of the above.

Q 20 - Which of the following element maps java.util.Set property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 21 - Which of the following element maps java.util.List property in hibernate?

A - <set>

B - <list>

C - <bag>
D - <map>

Q 22 - Which of the following element maps java.util.Collection property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 23 - Which of the following element maps java.util.Map property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 24 - Which of the following element maps java.util.SortedMap property in


hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 25 - Which of the following element is used to represent many-to-one relationship


in hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above

ANSWER SHEET

Question Number Answer Key

1 A

2 A

3 B

4 A

5 A
6 B

7 A

8 C

9 C

10 A

11 A

12 C

13 D

14 A

15 D

16 B

17 C

18 C

19 D

20 A

21 B

22 C

23 D

24 D

25 A

Loading [MathJax]/jax/output/HTML-CSS/jax.js
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST III

Q 1 - Which of the following element is used to represent one-to-one relationship in


hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above.

Q 2 - Which of the following element is used to represent one-to-many relationship in


hibernate?

A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

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

Q 4 - Which of the following element is used to represent one-to-many relationship in


hibernate?
A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

Q 5 - Which of the following situation represents many-to-many relationship?

A - An employee can have multiple certificates and same certificate can be conferred to many
employees.

B - An employee can have multiple certificates.

C - A certificate can be conferred to many employees.

D - All of the above.

Q 6 - What is the difference between save and persist methods of session object?

A - There is no difference.

B - save saves the object and returns status whereas persist stores status in different variable.

C - save saves the object and returns the id of the instance whereas persist do not return
anything after saving the instance.

D - None of the above.

Q 7 - What is the difference between get and load methods of session object?

A - get returns null if no data is present where as load throws ObjectNotFoundException


exception in such case.

B - get always hits the database whereas load method doesn't hit the database.

C - get returns actual object whereas load returns proxy object.

D - All of the above.

Q 8 - What is lazy loading?

A - Lazy loading is a technique in which objects are loaded on demand basis.

B - Lazy loading is a technique in which objects are persisted on demand basis.

C - Both of the above.

D - None of the above.

Q 9 - What is value of lazy loading by default?

A - true

B - false
Q 10 - Child objects are not loaded when parent is loaded/populated from database.
What this technique is called?

A - Eager Loading

B - Lazy Loading

C - Request based Loading

D - None of the above.

Q 11 - What HQL stands for?

A - Hibernate Query Language

B - High Query Language

C - Hybrid Query Language

D - None of the above.

Q 12 - Which of the following is true about HQL?

A - HQL takes java objects in the same way as SQL takes tables.

B - HQL is a Object Oriented Query language

C - HQL is database independent.

D - All of the above.

Q 13 - What is first level cache in hibernate?

A - The first-level cache is the Session based cache.

B - The first-level cache is the SessionFactory based cache.

C - Both of the above.

D - None of the above.

Q 14 - Whis of the following is true about first level cache in hibernate?

A - The first-level cache is the Session cache.

B - The first-level cache is a mandatory cache through which all requests must pass.

C - The Session object keeps an object under its own power before committing it to the database.

D - All of the above.

Q 15 - What is second level cache in hibernate?

A - The second-level cache is the SessionFactory based cache and is mainly responsible for
caching objects across sessions.

B - The second-level cache is the Session based cache.


C - Both of the above.

D - None of the above.

Q 16 - Whis of the following is true about second level cache in hibernate?

A - The second-level cache is the SessionFactory based cache.

B - The second-level cache can be configured on a per-class and per-collection basis.

C - The second-level cache is mainly responsible for caching objects across sessions.

D - All of the above.

Q 17 - Is first level caching mandatory in hibernate?

A - true

B - false

Q 18 - Is second level caching mandatory in hibernate?

A - true

B - false

Q 19 - Is query level caching mandatory in hibernate?

A - true

B - false

Q 20 - What is Query level cache in hibernate?

A - The query-level cache is cache for query resultsets that integrates closely with the second-
level cache.

B - The query-level cache is the Session based cache.

C - Both of the above.

D - None of the above.

Q 21 - Which of the following is true about query level cache in hibernate?

A - Query level cache is an optional feature.

B - Query level cache requires two additional physical cache regions that hold the cached query
results and the timestamps when a table was last updated.

C - Query level cache is only useful for queries that are run frequently with the same parameters.

D - All of the above.

Q 22 - Which of the following is a concurrency strategies in hibernate?


A - Transactional

B - Read-write

C - Nonstrict-read-write.

D - All of the above.

Q 23 - When a Transactional concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

Q 24 - When a Read-write concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

Q 25 - When a Nonstrict-read-write concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

ANSWER SHEET

Question Number Answer Key

1 A

2 A

3 A

4 A

5 A

6 C
7 D

8 A

9 A

10 B

11 A

12 D

13 A

14 D

15 A

16 D

17 A

18 B

19 B

20 A

21 D

22 D

23 B

24 B

25 C

Loading [MathJax]/jax/output/HTML-CSS/jax.js
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST IV

Q 1 - When a Read-only concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

Q 2 - Which of the following is true with respect to ORM vs JDBC?

A - ORM system lets business code access objects rather than DB tables.

B - ORM system hides details of SQL queries from OO logic.

C - ORM system helps in Transaction management and automatic key generation.

D - All of the above.

Q 3 - Which of the following is true about hibernate?

A - Hibernate does not require an application server to operate.

B - Hibernate manipulates Complex associations of objects of your database.

C - Hibernate minimize database access with smart fetching strategies.

D - All of the above.

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

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

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

A - Transaction

B - SessionFactory

C - Session

D - All of the above

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

A - true

B - false

Q 8 - The SessionFactory is heavyweight object.

A - false

B - true

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

A - false

B - true

Q 10 - A Session is used to get a physical connection with a database.

A - true

B - false

Q 11 - The Session object is lightweight.

A - false
B - true

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

A - false

B - true

Q 13 - Which of the following is true about hibernate annotations?

A - Hibernate Annotations is the powerful way to provide the metadata for the Object and
Relational Table mapping.

B - 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.

C - Both of the above.

D - None of the above.

Q 14 - Which of the following is true about @Id annotation?

A - Hibernate detects that the @Id annotation is on a field.

B - Hibernate assumes that it should access properties on an object directly through fields at
runtime.

C - Both of the above.

D - None of the above.

Q 15 - Which of the following is true about @Entity annotation?

A - @Entity annotation marks a class as an entity bean.

B - Class marked with @Entity annotation must have a no-argument constructor that is visible
with at least protected scope.

C - Both of the above.

D - None of the above.

Q 16 - Which of the following is true about @Table annotation?

A - The @Table annotation allows to specify the details of the table that will be used to persist the
entity in the database.

B - The @Table annotation allows to override the name of the table, its catalogue, and its
schema, and enforce unique constraints on columns in the table.

C - Both of the above.

D - None of the above.

Q 17 - Which of the following is true about @GeneratedValue annotation?


A - @GeneratedValue annotation takes two parameters strategy and generator.

B - @GeneratedValue annotation provides the primary key generation strategy to be used.

C - Both of the above.

D - None of the above.

Q 18 - Which of the following is true about @Column annotation?

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

B - The @Column annotation is applied on a class.

C - Both of the above.

D - None of the above.

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


explicitly specified.

A - true

B - false

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

Q 21 - nullable attribute of @Column annotation permits the column to be marked


NOT NULL when the schema is generated.

A - true

B - false

Q 22 - Which of the following is true about HQL?

A - Hibernate Query Language HQL is an object-oriented query language.

B - Instead of operating on tables and columns, HQL works with persistent objects and their
properties.

C - Both of the above.

D - None of the above.

Q 23 - Which of the following is true about HQL?

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

C - Both of the above.

D - None of the above.

Q 24 - Which of the following is true about HQL?

A - Hibernate supports named parameters in its HQL queries.

B - HQL supports a range of aggregate methods, similar to SQL.

C - Both of the above.

D - None of the above.

Q 25 - Which of the following is true about INSERT CLAUSE in HQL?

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

B - HQL supports INSERT INTO clause without any restriction.

C - Both of the above.

D - None of the above.

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 C

14 C

15 C

16 C
17 C

18 A

19 A

20 B

21 A

22 C

23 C

24 C

25 A

Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js
https://www.tutorialspoint.com/hibernate/hibernate_mock_test.htm?min=51&max=75
--------------------------------------------------------------------------------------------
1 - Which are the modules of Web layer?
A - WebSocket, Servlet, Web, Portlet (Modules in Web Layer of Spring framework)
B - WebSocket, Servlet, Web-MVC, Web
C - HTML, JSP, WEB, Portlet
D - HTML, Servlet, WEB, Portlet.

I. Web module: This provides basic web-oriented integration features.


II. Servlet module: Support for Servlet Listeners.
III. WebSocket module: Support for Web Socket style messaging.
IV. Portlet module: MVC implementation for Portlet environment.

2. How can you inject Java Collection in Spring?


A - Using list, set, map or props tag.
B - Using lit, set, map or collection tag.
C - Using list, set, props or collection tag.
D - Using list, collection, map or props tag.

4 major collection types are supported:


List – <list/>
Set – <set/>
Map – <map/>
Properties – <props/>
3. Length attribute of @Column annotation permits the size of the column used to map a value
particularly for a String value. (hibernate-annotations)
A - false
B – true
@Column(name = "id")
private int id;

4. How to auto-inject into a field a bean by its name?


Select one or more response.
1. With the name attribute of the @Autowired annotation
2. By using the single @Qualifier annotation
3. By using both the @Autowired and the @Qualifier spring annotations
4. By using the @Autowired annotation and naming the field with the bean name.
You can use @Qualifier along with @Autowired. In fact spring will ask you explicitly select the bean if
ambiguous bean type are found, in which case you should provide the qualifier:

@Component
@Qualifier("staff")
public Staff implements Person {}

@Component
@Qualifier("employee")
public Manager implements Person {}
@Component
public Payroll {

private Person person;

@Autowired
public Payroll(@Qualifier("employee") Person person){
this.person = person;
}

5. What are the modules of spring web flow?


a. Spring-faces
b. Spring-bundling
c. Spring-container
d. Spring-webflow

6.Which of the following statements are correct?


a.Bean Factory and ApplicationContext are basic container only
b.Bean Factory is basic container and ApplicationContext is advanced container
c.Bean Factory and ApplicationContext are advanced container
d.Bean Factory is advanced container and ApplicationContext is basic container

The ApplicationContext container includes all functionality of the BeanFactory container, so it is


generally recommended over the BeanFactory.

7.Which of the following, parses in XML based on expression and its used extensively in conjugation with
xstl ?
a)JDOM parser
b)SAX parser
c) STAX parser
d) Xpath parser

XML Parser provides a way to access or modify data in an XML document

8.In Spring MVC which of the following is the front controller class that initializes the context based on
the spring beans configuration?

a.org.springframework.web.servlet.DispatcherServlet
b.org.springframework.web.context.DispatcherServlet c.org.springframework.web.servlet
d.org.springframework.web.context.ApplicationContext
9.Given the following configuration class, what are correct affirmations?
public class ApplicationConfig {
private DataSource dataSource;
@Autowired
public ApplicationConfig(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean(name="clientRepository")
ClientRepository jpaClientRepository() {
return new JpaClientRepository();
}
}
1. @Configuration annotation is missing
2. Default or no-arg constructor is missing
3. @Bean name is ambiguous
4. @Bean scope is prototype

Annotating a class with the @Configuration indicates that the class can be used by the Spring IoC
container as a source of bean definitions.
The @Bean annotation tells Spring that a method annotated with @Bean will return an object that
should be registered as a bean in the Spring application context.
10.Which of the following is NOT the type of mapping?
a. Instance mapping
b. Component mapping
c. Association mapping
d. Class mapping

11.In spring bean configuration bean attribute called 'scope' defines what kind of object has to be
created and returned. What returns a new bean instance each time when required?
a.Prototype
b.Session
c.Singleton
d.Global session

12. Which of the following explains about addClass () in the listed options
jQuery addClass() Method:jQuery HTML/CSS methods

I. This function translates a Java class name into file name


II. This translated file name is then loaded as an input stream from the java class loader
III. This addClass () is important if you want efficient usage of classes in your code
a. I, II, and III
b. I and III
c. I and II
d. II and III

EXAMPLE:
→Using jQuery addClass() method to create zebra stripes effect in HTML table:
=>$(selector).addClass(classname,function(index,oldclass)) → SYNTAX
Index and oldclass are the 2 different classes added using ‘,’.

<script type="text/javascript"> $(function()


{ $("table tr:nth-child(even)").addClass("striped"); });
</script>

tr.striped { border: 1px outset silver; background-color: yellow; }

13.What are the benefits of Spring Framework's transaction management?


a. It Provides a consistent programming model across different transaction APIs such as JTA, JDBC,
Hibernate, JPA, and JDO.
b. It Supports declarative transaction management.
c. It Provides a simpler API for programmatic transaction management than a number of complex
transaction APIs such as JTA.
d. All the listed

14. The Model-View-Controller(MVC) is an architectural pattern that does not separate an application
into three main logical components: the model, the view and the controller.
a. true
b. False.

15. The application is designed around an object model. The SQL code is generated at build time and the
associations between objects are supported by the persistent mechanism, and queries are specified
using an object oriented expression language. This best suited for medium-sized applications with some
complex transactions. Used when the mapping exceeds 25 different database products at a time.
Which of the following is this called as?
a. Application Object Mapping
b. Expression object mapping
c. Medium Object Mapping
d. Object Mapping

16. XsltViewResolver-supports XsltView by resolving the view name of which of the following options
a) all of the listed options
b) VelocityView and its subclasses
c) URL of xslt
d)view name of the URL of the report file.

use the XsltView and XsltViewResolver in order to apply a XML stylesheet (XSL) for a specific XML
document, resulting in a view (typically an HTML page) transformed by the XSL document.
17. What types of views supported by spring MVC for different presentation technologies
a) JSP
b) HTML
c) velocity templates
d) select all

18. Spring is a heavy weight framework


True
False

19. A very powerful and high performance querying language used to Query, retrieve, store data in DB is
a) PLSQL
b) HQL
c) SQL
d) RDBMS

20.which is correct?
a. Hibernate is an object oriented query language
b. It is database independent
c.it supports pagination
d. HQL statements will be converted to SQL or other language the database supports
e. all the above

21. Which of the following is true about hibernate. Dialect property in hibernate configuration?
A - This property makes Hibernate generate the appropriate SQL for the chosen database.
B - This property makes Hibernate generate the appropriate java code for the chosen database.
C - Both of the above.
D - None of the above.

Dialect means "the variant of a language". Hibernate, as we know, is database agnostic. It can work with
different databases. Therefore, at some point hibernate has to use database specific SQL. Hibernate
uses "dialect" configuration to know which database you are using so that it can switch to the database
specific SQL generator code wherever/whenever necessary.

22. When a Read-only/non strict read-write concurrency strategy is to be used?


A - Use it for reference data only.
B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.
C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical
concern.
D - None of the above.

23. When a Read-write/transactional concurrency strategy is to be used?


A - Use it for reference data only.
B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.
C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical
concern.
D - None of the above.

24. How could you externalize constants from a Spring configuration file or a Spring annotation into
a.properties file? Select one or more answers
1. By using the <util:constant /> tag
2. By declaring the ConstantPlaceholderConfigurer bean post processor
3. By using the <context:property-placeholder /> tag
4. By using the c: namespace

------------ PropertyPlaceholderConfigurer bean in Spring’s application context ----------

<bean id="mailProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

<property name="location" value="classpath:mail.properties" />

</bean>
------------------------------ mail.properties ----------------------------------------
smtp.host=smtp.gmail.com
smtp.port=587
[email protected]
smtp.pass=secret
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${smtp.host}" />
<property name="port" value="${smtp.port}" />
<property name="username" value="${smtp.user}" />
<property name="password" value="${smtp.pass}" />
</bean>

25. Does sessionLocaleResolver interceptor detects if a special parameter is present in current Http req?
TRUE
FALSE

26. What is a DispatcherServlet?


A - DispatcherServlet is used for transaction management.
B - DispatcherServlet is used for AOP.
C - DispatcherServlet handles all the HTTP requests and responses.
D - DispatcherServlet is used for Dependency injection.

27. The test module supports the testing of spring components with junit for testing
a. true
b. false

28. Which is not a module in spring framework?


a. ORM
b. DAO
c. MVC
d. none

28. Following class can be extended to create custom event in spring.


A - SpringEvent
B - Event
C - ApplicationEvent
D - None of above

Create an event class, CustomEvent by extending ApplicationEvent. This class must define a default
constructor which should inherit constructor from ApplicationEvent class.

29. Which is the way to provide configuration metadata to spring?


A - XML Based configuration file: All configurations are in one or multiple XML files
B - Annotation based configuration: We still have to write XML files but just to indicate "component-
scan" on the packages of annotated classes.
C - Java based configuration (JavaConfig): We don't need any XML with this method of configuration.
JavaConfig provides a truly object-oriented mechanism for dependency injection, meaning we can take
full advantage of reusability, inheritance and polymorphism in the configuration code. Application
developer has complete control over instantiation and dependency injection here.
d – all of the above

Spring configuration metadata is to tell Spring container how to initiate, configure, wire and assemble
the application specific objects.

30. What is an after returning advice? Select a unique answer.


1. Advice to be executed regardless of the means by which a join point exits
2. Advice that surrounds a method invocation and can perform custom behavior before and
after the method invocation
3. Advice to be executed before method invocation
4. Advice to be executed after a join point completes without throwing an exception

After returning advice is invoked only on normal method return, not if an exception is thrown. Such
advice can see the return value, but cannot change it.
org.springframework.aop
Interface AfterReturningAdvice

31. Which of the following tools/frameworks provides integration with Hibernate?


A - XDoclet Spring
B - J2EE
C - Maven
D - All of the above.

32. Which of the following is the root node of hbm.xml file?


A - hibernate-mapping
B - hibernate-config
C - class-mapping
D - class-config

33. What is true about @Autowired annotation?


A - The @Autowired annotation can be used to autowire bean on the setter method.
B - This annotation provides more fine-grained control over where and how autowiring should be
accomplished.
C - The @Autowired annotation can be used to autowire bean on the methods with arbitrary names
and/or multiple arguments.
D - All of above

34. How do you turn on annotation wiring?


A - Add <annotation-context:config /> to bean configuration.
B - Add <annotation-config /> to bean configuration.
C - Add <annotation-context-config /> to bean configuration.
D - Add <context:annotation-config/> to bean configuration.

35.which of the following is an invalid annotation?


@RequestParam
@PathValid
@Responsevalid
@RequestMapping

36. Which of the following is true about Hibernate?


A - Hibernate is an Object-Relational Mapping (ORM) solution for JAVA.
B - Hibernate is an Object-Relational Mapping (ORM) solution for .NET
C - Both of the above.
D - None of the above.

37. Java based configuration option disables you to write most of your Spring configuration without XML
but with the help of few Java-based annotations
True
False

38. What is singleton scope?


A - This scopes the bean definition to a single instance per Spring IoC container.
B - This scopes the bean definition to a single instance per HTTP Request.
C - This scopes the bean definition to a single instance per HTTP Session.
D - This scopes the bean definition to a single instance per HTTP Application/ Global session.

39. Is first level caching mandatory in hibernate?


A - true
B - false
40.Which tool helps to generate the mapping document Though many Hibernate users choose to write
the XML by hand. select one
a) oldgen
b) younggen
c) Middlegen----------------ANS
d) Mediumgen

41. ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data
between relational databases. select one
True----------Ans
False

42. which type of annotation applies to bean property setter methods. select one
a) @Requires
b) @Resource
c) @Required----------------ANS
d)@Requiring

43. Element which can be used to inject a collection of name-value pairs where the name and the value
can be of any type. select one
a) <list>
b) <set>
c)<map>---------------ANS
d)<props>

44. Element which can be used to inject a collection of name-value pairs where the name and the value
are both Strings type. select one
a) <list>
b) <set>
c)<map>
d)<props>---------------ANS

45. ApplicationContext implements which of the following interface that is used to obtain localized
messages, with the actual implementation being pluggable
I. MessageSource
II. RequestMapping. Select One:
a. only I--------------ANS
b. only II
c. Neither I or II
d. Both I and II

46. How many layers are there in Hibernate architecture. select one
a)3
b)4------------Ans
c)5
d)2
47. What of the following is not correct in live environment? select one
a. Constructor and properties autowiring in the same bean are not compatible
b. A bean should have a default or a no-args constructor
c. The <constructor-arg> tag could take type, name and index to reduce ambiguity
d. All of the above-----------ANS

48. named queries are created via which level of annotations on entities?
a. all-level
b. high-level
c. low
d. class level------- ANS

49. how many bean scopes are specified in singleton by default?


a.6
b.7
c.5----------- ans
d. none

50. in controller which is responsible for rendering the page in spring mvc
a. browser
b. http----------ans
c. database
d. application

51. spring can organize which type of objects?


a. application later------ans
b. database layer--------ans
c. network------ans
d. browser

52. In Spring AOP, the process of linking aspect with other application types or objects to create an
advice object is called Weaving.

53. Can you inject null and empty string values in Spring? ans: yes

54. SpEL is NOT part of core container. ANS: false (it is part of core container)

55. how many instances can be created fora global session: one

56. what display the data with help of model? Ans: View

57. How after advice works?


A - Run advice after a method execution regardless of its outcome. -----ANS
B - Run advice after a class loads.
C - Run advice after http response is returned.
D - Run advice after http request is processed.

58. What is ContextStartedEvent event?


A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.
C - This event is published when the ApplicationContext is started using the start() method on the
ConfigurableApplicationContext interface.--ANS
D - This event is published when the HTTP Response is returned.

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


A - DB2/NT
B - MySQL
C - FoundationDB ----ANS
D - PostgreSQL

60. What is the difference between save() and persist() methods of session object?
A - There is no difference.
B - save saves the object and returns status whereas persist stores status in different variable.
C - save saves the object and returns the id of the instance whereas persist do not return anything after
saving the instance. ------ANS
D - None of the above.

61. what is required to write a basic spring program? ANS---- jdk, ide, maven, all the above

62. JDBC, ORM, OXM, JMS, Transactions are the modules of Data Access/ Integration layer. ------TRUE

63. ContextStartedEvent event is published when the ApplicationContext is started using the start ()
method on the ConfigurableApplicationContext interface. -----TRUE

64. singleton is the default scope of any spring bean. -----TRUE

65. ContextClosedEvent--------is published when the ApplicationContext is closed using the close()
method on the ConfigurableApplicationContext interface.

66. When we work with an object oriented system, there is mismatch between the object model and the
relational database. State True or False
a). TRUE-------------ANS
b). FALSE

67. Form tags are available in springs is more compatible with html tags for better development. State
True or False
a). TRUE-----------ANS
b). FALSE

68. index and type can be used in the constructor-arg at the same time? State True or False
a). TRUE-----ANS
b). FALSE

69. the same XSD of BeanFactory can be used for View resolver interface?State True or False
a). TRUE---------------ANS
b). FALSE
70. XML Mapping file offers which of the following? Select One:
a. Readable Metadata
b. Surrogate key generation strategy
c. Collection metadata
d. all the listed options---------ANS
e. Column/Table Mapping

71. Which of the following aspects of a project can be managed using Maven?
A - Distribution
B - mailing list
C - Both of the above. ------Ans
D - None of the above.

Builds, Documentation, Reporting, Dependencies, SCMs, Releases

72. which one is incorrect?


object is the superclass of all other classes
object does not support encapsulation--------Ans

73. where multiple components are involved in processing the request in a single transaction, which
method is used to get the session object.
a) opensession()
b) getsession()
c) getcurrentsession()
d) all of the above---ans

73. which statement is not correct about HQL


a) it is an object oriented query language
b) it supports all types of operation i.e DML DDL FROM Hibernate 1.x to till now---ans
c) it supports pagination
d)HQL queries are compiled to sql of a database or any other native query language the target database
supports.

74. which state does the persistent object move to when the transaction is committed and the session is
closed?
a) permanent
b) detached---ans
c) initial
d) persistent

75. which hibernate property do you use to configure your chosen database.
a) hibernate.configdatabase
b) hibernate.changedatabase
c) hibernate.setdatabase
d) hibernate.dialect----ans
76. Which of the following tags generated by the form tag library compliant with XHTML-1.0-Strict
specification and attendant DTD.
“The button tag”
“The checkbox tag”
“The checkboxes tag”
“The errors tag”
“The form tag”
“The hidden tag”
“The input tag”
“The label tag”
“The option tag”
“The options tag”
“The password tag”
“The radiobutton tag”
“The radiobuttons tag”
“The select tag”
“The textarea tag”

77. Template engine is primarily aimed at generating which of the following XML?
a. Java
b. XML---ANS
c. XHTML---ANS
d. HTML5----ANS

78. The Spring form tag library comes bundled in spring-webmvc.jar. State True or false
a. true----ans
b. false

79. Which of the following tags are not available in XML schema based configuration
ANS: JDX-marsheller

80. Which of the following is not a major considerations of spring web application
a. Interactive and Richness
b. User-Friendly
c. Performance
d. Tough accessibility---ans

81. By using which of the following will return if caching is enabled?


a. TheCache()
b. isCache()----Ans
c. iscacheResolved()
d. LoadView()
82. spring security framework focuses on which of the following?
a. providing authentication to Java applications
b. providing authorization to Java applications
c. providing both authentication and authorization to Java applications---ANS
d. none of the listed options.

Expected Questions: ----------------------------------------------------------------

83. In Spring AOP, 4 type of advices are supported:


before-----Run advice before the method execution.
after------Run advice after the method execution, regardless of its outcome.
after-returning advice-----Run advice after the method execution, only if the method completes
successfully.
after-throwing advice-----Run advice after the method execution, only if the method exits by throwing
an exception.
around-----Run advice before and after the advised method is invoked.

84.
ResourceLoader support: Spring's Resource interface use a flexible generic abstraction for handling low-
level resources. An application context itself is a ResourceLoader, hence provides an application with
access to deployment-specific Resource instances.

MessageSource support: The application context implements MessageSource, an interface used to


obtain localized messages, with the actual implementation being pluggable.

85. Which of the following are the best practices for writing spring XML Configurations?

1) Add a header comment to each configuration file


2) Use consistent naming conventions
3) No version numbers in schema references
4) Prefer setter injection over constructor injection
5) Prefer type over index for constructor argument matching
6) Use shortcut forms over expanded forms
7) Reuse bean definitions as much as possible
8) Always use ids as bean identifiers
9) Try to avoid autowiring
10) Always use classpath prefix
11) Always externalize properties
12) Use dependency-check at the development phase
13) Do not abuse/overuse dependency injection

86. Spring framework architecture:


------------------------------------------------------------------------------------------------
Data Access/Integration--JDBC, ORM, OXM, JMS, Transactions
Web(MVC/Remoting) -- WebSocket, Servlet, Web, Portlet
AOP
Aspects
Instrumentation
Messaging
Core container--Beans, Core, Context and spEL
Test

87.
Spring BeanFactory Container-org.springframework.beans.factory.BeanFactoryinterface.
Spring ApplicationContext Container-org.springframework.context.ApplicationContext

88. Bean Scopes:


--------------------------------------------------------------------------------------------

Scope: Description

Singleton: This scopes the bean definition to a single instance per Spring IoC container (default).

Prototype: This scopes a single bean definition to have any number of object instances.

Request: This scopes a bean definition to an HTTP request. Only valid in the context of a web-aware
Spring ApplicationContext.

Session: This scopes a bean definition to an HTTP session. Only valid in the context of a web-aware
Spring ApplicationContext.

global-session: This scopes a bean definition to a global HTTP session. Only valid in the context of a web-
aware Spring ApplicationContext.

89. Spring-Injecting Collection:


-----------------------------------------------------------------------------------------

Element Description

<list> ->This helps in wiring i.e., injecting a list of values, allowing duplicates.
<set> ->This helps in wiring a set of values but without any duplicates.
<map> ->This can be used to inject a collection of name-value pairs where the name and the value can
be of any type.
<props> ->This can be used to inject a collection of name-value pairs where the name and the value are
both Strings.
90. Autowiring Modes:
-----------------------------------------------------------------------------------------

Mode Description

No => This is a default setting which means no autowiring and you should use explicit bean reference for
wiring. You have to do nothing special for this wiring. This is what you already have seen in Dependency
Injection chapter.

byName => Autowiring by property name. Spring container looks at the properties of the beans on
which autowire attribute is set to byName in the XML configuration file. It then tries to match and wire
its properties with the beans defined by the same names in the configuration file.

byType=>Autowiring by property datatype. Spring container looks at the properties of the beans on
which attribute is set to byType in the XML configuration file. It then tries to match and wire a property
if its type matches with exactly one of the beans name in the configuration file. If more than one such
beans exists, a fatal exception is thrown.

Constructor=>Similar to byType, but this type applies to constructor arguments. If there is not exactly
one bean of the constructor argument type in the container, a fatal error is raised.

autodetect =>Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

Autowiring Limitations:
-------------------------------------------------------------------------------------
Limitations Description

Overriding possibility-----You can still specify dependencies using <constructor-arg> and <property>
settings which will always override autowiring.

Primitive data types------You cannot autowire so-called simple properties such as primitives, Strings, and
Classes.

Confusing nature------Autowiring is less exact than explicit wiring, so if possible prefer using explicit
wiring.

91.
@Required-----The @Required annotation applies to bean property setter methods
@Autowired----The @Autowired annotation can apply to bean property setter methods, nonsetter
methods, constructor and properties.

@Qualifier----The @Qualifier annotation along with @Autowired can be used to remove the confusion
by specifying which exact bean will be wired.

JSR-250 Annotations----Spring supports JSR-250 based annotations which include @Resource,


@PostConstruct and @PreDestroy annotations. (Go through these annotations also)

92.
@Configuration-----indicates that the class can be used by the Spring IoC container as a source of bean
definitions.

@Bean-----annotation tells Spring that a method annotated with @Bean will return an object that
should be registered as a bean in the Spring application context

@Import-----annotation allows for loading @Bean definitions from another configuration class

93. Spring Event Handling:


----------------------------------------------------------------------------------

ContextRefreshedEvent-----This event is published when the ApplicationContext is either initialized or


refreshed. This can also be raised using the refresh() method on the ConfigurableApplicationContext
interface.

ContextStartedEvent-------This event is published when the ApplicationContext is started using the


start() method on the ConfigurableApplicationContext interface. You can poll your
database or you can restart any stopped application after receiving this event.

ContextStoppedEvent-------This event is published when the ApplicationContext is stopped using the


stop() method on the ConfigurableApplicationContext interface. You can do the required
housekeep work after receiving this event.

ContextClosedEvent--------This event is published when the ApplicationContext is closed using the close()
method on the ConfigurableApplicationContext interface. A closed context reaches its
end of life; it cannot be refreshed or restarted.

RequestHandledEvent-------This is a web-specific event telling all beans that an HTTP request has been
serviced.

94. AOP Terminologies:


-------------------------------------------------------------------------------------

Terms Description
Aspect->This is a module which has a set of APIs providing cross-cutting requirements. For example, a
logging module would be called AOP aspect for logging. An application can have any number of aspects
depending on the requirement.

Join Point->This represents a point in your application where you can plug-in the AOP aspect. You can
also say, it is the actual place in the application where an action will be taken using Spring AOP
framework.

Advice->This is the actual action to be taken either before or after the method execution. This is an
actual piece of code that is invoked during the program execution by Spring AOP framework.

Pointcut->This is a set of one or more join points where an advice should be executed. You can specify
pointcuts using expressions or patterns as we will see in our AOP examples.

Introduction->An introduction allows you to add new methods or attributes to the existing classes.

Target Object->The object being advised by one or more aspects. This object will always be a proxied
object, also referred to as the advised object.

Weaving->Weaving is the process of linking aspects with other application types or objects to create an
advised object. This can be done at compile time, load time, or at runtime.

95. Custom Aspects Implementation:


---------------------------------------------------------------------------

Approach Description

XML Schema based→Aspects are implemented using the regular classes along with XML based
configuration.

@AspectJ based→@AspectJ refers to a style of declaring aspects as regular Java classes annotated with
Java 5 annotations.

96. Spring Transaction Management:


--------------------------------------------------------------------------------

ACID:

Atomicity: A transaction should be treated as a single unit of operation, which


means either the entire sequence of operations is successful or unsuccessful.
Consistency: This represents the consistency of the referential integrity of the
database, unique primary keys in tables, etc.

Isolation: There may be many transaction processing with the same data set at
the same time. Each transaction should be isolated from others to prevent data
corruption.

Durability: Once a transaction has completed, the results of this transaction have
to be made permanent and cannot be erased from the database due to system
failure.

Methods and description:


---------------------------------------------

TransactionStatus.getTransaction(TransactionDefinition definition)→This method returns a currently


active transaction or creates a new one, according to the specified propagation behavior.

void commit(TransactionStatus status) →This method commits the given transaction, with regard to its
status.

void rollback(TransactionStatus status) →This method performs a rollback of the given transaction.

int getPropagationBehavior()→This method returns the propagation behavior. Spring offers all of the
transaction propagation options familiar from EJB CMT.

int getIsolationLevel()→This method returns the degree to which this transaction is isolated from the
work of other transactions.

String getName()→This method returns the name of this transaction.

int getTimeout()→This method returns the time in seconds in which the transaction must complete.

boolean isReadOnly()→This method returns whether the transaction is read-only.

97. isolation levels:


--------------------------------
TransactionDefinition.ISOLATION_DEFAULT→This is the default isolation level.

TransactionDefinition.ISOLATION_READ_COMMITTED→Indicates that dirty reads are prevented; non-


repeatable reads and phantom reads can occur.

TransactionDefinition.ISOLATION_READ_UNCOMMITTED→Indicates that dirty reads, non-repeatable


reads, and phantom reads can occur.

TransactionDefinition.ISOLATION_REPEATABLE_READ→Indicates that dirty reads and non-repeatable


reads are prevented; phantom reads can occur.

TransactionDefinition.ISOLATION_SERIALIZABLE →Indicates that dirty reads, non-repeatable reads, and


phantom reads are prevented.

98. Propagation types:


-------------------------------------------

TransactionDefinition.PROPAGATION_MANDATORY→ Supports a current transaction; throws an


exception if no current transaction exists.

TransactionDefinition.PROPAGATION_NESTED→Executes within a nested transaction if a current


transaction exists.

TransactionDefinition.PROPAGATION_NEVER→ Does not support a current transaction; throws an


exception if a current transaction exists.

TransactionDefinition.PROPAGATION_NOT_SUPPORTED→Does not support a current transaction;


rather always execute nontransactionally.

TransactionDefinition.PROPAGATION_REQUIRED→Supports a current transaction; creates a new one if


none exists.

TransactionDefinition.PROPAGATION_REQUIRES_NEW →Creates a new transaction, suspending the


current transaction if one exists.

TransactionDefinition.PROPAGATION_SUPPORTS→Supports a current transaction; executes non-


transactionally if none exists.

TransactionDefinition.TIMEOUT_DEFAULT→Uses the default timeout of the underlying transaction


system, or none if timeouts are not supported.

100. There are four fetching strategies

1. fetch- “join” = Disable the lazy loading, always load all the collections and entities.
2. fetch- “select” (default) = Lazy load all the collections and entities.
3. batch- size =” N” = Fetching up to ‘N’ collections or entities, *Not record*.
4. fetch- “subselect” = Group its collection into a sub select statement.

------------------------------------------------------------------------------------------------------------
Topics to read:

* HQL
*Tools in hibernate
*Interceptors in hibernate
*Annotations in both spring and hibernate
*specifications for Java API (e.g.: JSR-250, JSR-303)
*Interfaces and classes in both spring and hibernate (e.g.: ViewResolver is an interface)
*Mapping in hibernate (e.g.: Middlegen is a tool)

1. different fetching strategy of hibernate?


2. what are the aspects project manager using maven?
Distribution
mailing list
address list
3. what are the different presentation technique?
Jsp, lotusnotes, HTML
4. how to disable the second cache?

Q 1 - Which of the following is correct about dependency injection?

A - It helps in decoupling application objects from each other.

B - It helps in deciding the dependencies of objects.

C - It stores objects states in database.

D - It stores object states in file system.

Q 2 - Which of the following stands true for spring beans?

A - Spring beans are managed by the Spring IoC container.

B - Spring beans are instantiated, assembled, and otherwise managed by a Spring IoC container.

C - Spring beans are simple POJOs.

D - All of the above.


Q 3 - What is true about <list> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This can be used to inject a collection of name-value pairs where the name and value are
both Strings.

Q 4 -Can you inject null and empty string values in Spring?


A - Yes
B - No

Q 5 - What is Advice?

A - This is the way to instruct object to behave in certain manner.

B - This is used to inject values in objects.

C - This is the actual action to be taken either before or after the method execution.

D - This is not invoked during program execution by Spring AOP framework.

Q 6 - What is Introduction?

A - An introduction represents a point in your application where you can plug-in AOP aspect.

B - This is used to inject values in objects.

C - This is not invoked during program execution by Spring AOP framework.

D - An introduction allows you to add new methods or attributes to existing classes.

Q 7 - How to use ref keyword in beans.xml?

A - Using setter method only.


B - Using constructor argument only.

C - Using setter method and constructor argument both.

D - None of the above.

Q 8 - By default a bean is eagerly loaded.

A - False

B - True

Q 9 -A bean must have id attribute in beans configuration file.


A - True
B - False

Q 10 - What is a DispatcherServlet?

A - DispatcherServlet is used for transaction management.

B - DispatcherServlet is used for AOP.

C - DispatcherServlet handles all the HTTP requests and responses.

D - DispatcherServlet is used for Dependency injection.

Q 11 - Which of the statement is not correct?

A - Core and beans modules provide the fundamental parts of the framework, including
Dependency Injection feature.

B - The SpEL module provides a powerful Expression Language for querying and manipulating
an object graph at runtime.

C - Aspects module provides integration with AspectJ.

D - None of the above.

Q 12 - What is singleton scope?


A - This scopes the bean definition to a single instance per Spring IoC container.

B - This scopes the bean definition to a single instance per HTTP Request.

C - This scopes the bean definition to a single instance per HTTP Session.

D - This scopes the bean definition to a single instance per HTTP Application/ Global session.

Q 13 - What is ContextClosedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP Response is returned.

D - This event is published when the ApplicationContext is closed using the close() method on
the ConfigurableApplicationContext interface.

Q 14 - What is Weaving?

A - Weaving is the process of injecting values in objects to create an advised object.

B - Weaving is the process of linking aspects with other application types or objects to create an
advised object.

C - This is used to inject values in objects.

D - Weaving is used to check object dependencies.

Q 15 - Which ORM Spring supports ?

A - Hibernate

B - iBatis

C - JPA

D - All of above.
Q 16 - What stands true for spring framework?

A - Spring framework is a light weight framework.

B - Spring framework is a heavy weight framework.

Q 17 - How to handle shut down of IoC container?

A - Using shutdownHook()

B - Using shutdownHandler()

C - Using registerHook()

D - Using registerShutdownHook()

Q 18 - Which of the following class can be used to execute Sql queries in spring?

B - JDBCHelper

A - JdbcTemplate

C - DBHelper

D - DBTemplate

Q 19 - Which is the correct implementation class of BeanFactory?

A - XmlBeanFactory

B - ClassPathBeanFactory

C - FileSystemBeanFactory

D - AdvancedBeanFactory

Q 20 - What is bean autowiring?


A - Autowiring lets Spring resolve collaborators (other beans) for your bean by inspecting the
contents of the BeanFactory without using <constructor-arg> and <property> elements.

B - Autowiring injects values in spring beans.

C - Autowiring injects one bean into another.

D - Autowiring helps in wiring a list of values, allowing duplicates.

Q 21 - How to get object of a service in spring framework?

A - Using new keyword

B - Using dependency injection

Q 22 - If a bean is scoped to HTTP request, scope is

A - session

B - global-session

C - prototype

D - request

Q 23 - Can be bean be configured to have an inner bean?

A - True

B - False

Q 24 - Which are the modules of Web layer?

A - WebSocket, Servlet, Web, Portlet

B - WebSocket, Servlet, Web-MVC, Web

C - HTML, JSP, WEB, Portlet

D - HTML, Servlet, WEB, Portlet


Q 25 - What is global-session scope?

A - This scopes a bean definition to an HTTP Application/ Global session.

B - This scopes the bean definition to Spring IoC container.

C - This scopes the bean definition to HTTP request.

D - This scopes the bean definition to HTTP Session.

Q 26 - What is Target object?

A - A represents a object in your application where you can plug-in AOP aspect.

B - The object being advised by one or more aspects, this object will always be a proxy object,
also referred to as the advised object.

C - This is used to inject values in objects.

D - This is not invoked during program execution by Spring AOP framework.

Q 27 - Core container has AOP as one of its module.

A - True

B - False

Q 28 - Which class is used to map a database row to a java object in spring?

A - ResultSet

B - RowMapper

C - RowSetMapper

D - ResultSetMapper

Q 29 - Which are the modules of Data Access/ integration layer?


A - JDBC, ORM, OXM, JMS, Transactions

B - JDBC, ORM, OXM, JMS

C - JDBC, ORM, Web, Beans

D - JDBC, ORM, OXM, JMS

Q 30 - Which of the statement is correct?

A - The JDBC module provides a JDBC-abstraction layer that removes the need to do tedious
JDBC related coding.

B - The ORM module provides integration layers for popular object-relational mapping APIs,
including JPA, JDO, Hibernate, and iBatis.

C - The Java Messaging Service JMS module contains features for producing and consuming
messages.

D - All of the above.

Q 31 - What is true about <map> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This tag is not supported.

Q 32 - What is true about @Autowired annotation?

A - The @Autowired annotation can be used to autowire bean on the setter method.

B - This annotation provides more fine-grained control over where and how autowiring should
be accomplished.
C - The @Autowired annotation can be used to autowire bean on the methods with arbitrary
names and/or multiple arguments.

D - All of above.

Q 33 - How do you turn on annotation wiring?

A - Add <annotation-context:config /> to bean configuration.

B - Add <annotation-config /> to bean configuration.

C - Add <annotation-context-config /> to bean configuration.

D - Add <context:annotation-config/> to bean configuration.

Q 34 - How after-throwing advice works?

A - Run advice after a method execution only if method exits by throwing an exception.

B - Run advice after a class loads only if class throws exception during load time.

C - Run advice after http response is returned with error status.

D - Run advice after http request is processed and an exception occurred.

Q 35 - Expression Language/ SpEL was introduced in which version of spring framework.

A - 1.0

B - 2.0

C - 3.0

D - 4.0

Q 36 - Can we inject value and ref both together in a bean?

A - True

B - False
Q 37 - What is true about <set> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This can be used to inject a collection of name-value pairs where the name and value are
both Strings.

Q 38 - What are the different points where weaving can be applied?

A - Compile time, load time

B - Compile time, run time

C - Run time

D - Compile time, load Time, Run time

Q 39 - Which of the following is part of Data Access layer in Spring framework?

A - Beans

B - Aspects

C - JMS

D - Context

Q 40 - What BeanPostProcessor does?

A - It processes beans once a bean is initialized.

B - It defines callback methods that you can implement to provide your own instantiation logic,
dependency-resolution logic etc.
C - It processes beans once a bean is loaded.

D - It processes beans once a bean exits.

Q 41 - Which are the IoC containers in Spring?

A - BeanFactory, ApplicationContext

B - BeanFactory, ApplicationContext, IocContextFactory

C - BeanFactory, BeanContext, IocContextFactory

D - BeanFactory, ApplicationContext, BeanContext

Q 42 - What is no mode of autowiring?

A - Default setting which means no autowiring and you should use explicit bean reference for
wiring.

B - Autowiring by property name.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Similar to byType, but type applies to constructor arguments.

Q 43 - What is ContextRefreshedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP Response is returned.

D - This event is published when the ApplicationContext is either initialized or refreshed.

Q 44 - How after-returning advice works?

A - Run advice after a class loads only if class loads successfully.


B - Run advice after a method execution only if method completes successfully.

C - Run advice after http response is returned only if http response is success.

D - Run advice after http request is processed with no exception.

Q 45 - What are the types of the transaction management Spring supports?

A - Programmatic transaction management

B - Declarative transaction management

C - Both of above.

D - None of above.

Q 46 - What is true about cross-cutting concerns?

A - The functions that span multiple points of an application are called cross cutting concerns.

B - Cross-cutting concerns are conceptually separate from the application's business logic.

C - Logging is one of the examples of cross cutting concerns.

D - All of the above.

Q 47 - Which is the way to provide configuration metadata to spring?

A - XML Based configuration file.

B - Annotation based configuration.

C - Java based configuration.

D - All of the above.

Q 48 - What is true about <props> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.


B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This can be used to inject a collection of name-value pairs where the name and value are
both Strings.

Q 49 - What is byType mode of autowiring?

A - Default setting which meas no autowiring and you should use explicit bean reference for
wiring.

B - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Autowiring by property type. Spring tries to match and wire a property if its type matches
with exactly one of the beans name in configuration file.

Q 50 - What is Join point?

A - This represents a point in your application which joins two objects.

B - This represents a point in your object where you join values.

C - This represents a point in your object where you join injected values.

D - This represents a point in your application where you can plug-in AOP aspect.

Q 51 - What are the ways to access Hibernate by using Spring?

A - Inversion of Control with a Hibernate Template and Callback.

B - Extending HibernateDAOSupport and Applying an AOP Interceptor node.

C - Both of above.

D - None of above.
Q 52 - SpEL is part of core container.

A - False

B - True

Q 53 - If a bean can be created any number of times, scope is

A - session

B - global-session

C - prototype

D - request

Q 54 - What is spring?

A - Spring is an open source development framework for enterprise Java.

B - Spring is a proprietary framework.

C - Spring is a development framework for .Net applications.

D - Spring is a development framework for PHP based applications.

Q 55 - What is prototype scope?

A - This scopes a single bean definition to have any number of object instances.

B - This scopes the bean definition to a single instance per HTTP Request.

C - This scopes the bean definition to a single instance per HTTP Session.

D - This scopes the bean definition to a single instance per HTTP Application/ Global session.

Q 56 - What does @Required annotation mean?


A - This annotation indicates that bean property must be populated by the user.

B - This annotation indicates that bean property is required while saving the bean data to
database.

C - This annotation simply indicates that the affected bean property must be populated at
configuration time, through an explicit property value in a bean definition or through
autowiring.

D - This annotation indicates that bean property is required while serializing the bean.

Q 57 - How before advice works?

A - Run advice before a class loads.

B - Run advice before a method execution.

C - Run advice before http response is to be returned.

D - Run advice before http request is to be processed.

Q 58 - Which of the following database is not supported using jdbcTemplate?

A - MySql

B - PostgresSql

C - NoSql

D - Oracle

Q 59 - What is the scope of stateless bean?

A - global-session

B - singleton

C - prototype

D - request
Q 60 - Which are the modules of core container?

A - Beans, Core, Context, SpEL

B - Core, Context, ORM, Web

C - Core, Context, Aspects, Test

D - Bean, Core, Context, Test

Q 61 - How can you inject Java Collection in Spring?

A - Using list, set, map or props tag.

B - Using lit, set, map or collection tag.

C - Using list, set, props or collection tag.

D - Using list, collection, map or props tag.

Q 62 - What is aspect?

A - Aspect is a way to do the dependency injection.

B - A module which has a set of APIs providing cross-cutting requirements.

C - Aspect is used to log information of application.

D - Aspect represents properties of spring based application.

Q 63 - What are the types of advice?

A - then, after, after-returning, after-throwing, around

B - When, after, after-returning, around

C - Where, after, after-returning, after-throwing, around

D - Before, after, after-returning, after-throwing, around


Q 64 - Can we integrate Struts with Spring.

A - Yes
B - No

Q 65 - Which are the different modes of autowiring?

A - no, byName, byType, constructor, autodetect

B - no, byName, byType, constructor, autocorrect

C - byName, byContent, constructor, autodetect

D - byName, byContent, setter, autodetect

Q 66 - By default a bean is eagerly loaded.

A - False
B - True

Q 67 - Where do you define DispatcherServlet?

A - In Beans configuration file.

B - Web.xml file

C - Meta-inf/dispatcher.xml

D - Web-inf/ dispatcher.xml

Q 68 - How after advice works?

A - Run advice after a method execution regardless of its outcome.

B - Run advice after a class loads.

C - Run advice after http response is returned.

D - Run advice after http request is processed.


Q 69 - What is true about BeanPostProcessor?

A - It is a concrete class.

B - It is an interface.

C - It is an abstract class.

D - None of the above.

Q 70 - What is ContextStartedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the ApplicationContext is started using the start() method on
the ConfigurableApplicationContext interface.

D - This event is published when the HTTP Response is returned.

Q 71 - What is Spring MVC framework?

A - Spring MVC framework is Model-Value-Class architecture and used to bind model data with
values.

B - The Spring web MVC framework provides model-view-controller architecture and ready
components that can be used to develop flexible and loosely coupled web applications.

C - Spring MVC framework is used for Transaction management for Web Applications.

D - Spring MVC framework is used for AOP for Web Applications.

Q 72 - What is @Controller annotation?

A - The @Controller annotation indicates that a particular class serves the role of a controller.

B - The @Controller annotation indicates how to control the transaction management.


C - The @Controller annotation indicates how to control the dependency injection.

D - The @Controller annotation indicates how to control the aspect programming.

Q 73 - What is ACID in transactional management?

A - Accurate, Controlled, Isolation, Durability

B - Atomicity, Consistency, Independent, Done

C - Atomicity, Consistency, Isolation, Durability

D - Accurate, Controlled, Independent, Done

Q 74 - What is RequestHandledEvent:event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP session is initialized or refreshed.

D - This event is published when the HTTP Request is serviced.

Q 75 - Which of the following stands true for spring beans?

A - Spring beans are managed by the Spring IoC container.

B - Spring beans are instantiated, assembled, and otherwise managed by a Spring IoC container.

C - Spring beans are simple POJOs.

D - All of the above.

Q 76 - What is default scope of bean in Spring framework?

A - singleton

B - prototype
C - request

D - session

Q 77 - What is the scope of bean in portlet context?

A - session

B - global-session

C - prototype

D - request

Q 78 - Following class can be extended to create custom event in spring.

A - SpringEvent

B - Event

C - ApplicationEvent

D - None of above

Q 79 - What is autodetect mode of autowiring?

A - Similar to byType, but type applies to constructor arguments. If there is not exactly one
bean of the constructor argument type in the container, a fatal error is raised.

B - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Autowiring by property type. Spring tries to match and wire a property if its type matches
with exactly one of the beans name in configuration file.

Q 80 - What is Pointcut?
A - This represents a point in your application where you can plug-in AOP aspect.

B - This is a set of one or more joinpoints where an advice should be executed.

C - This is used to inject values in objects.

D - This is invoked during program execution by Spring AOP framework.

Q 81 - Which class acts as IoC Container?

A - ServletContext

B - DispatcherServlet

C - ApplicationContext

D - None of the above

Q 82 - What is constructor mode of autowiring?

A - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

B - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

C - Autowiring by property type. Spring tries to match and wire a property if its type matches
with exactly one of the beans name in configuration file.

D - Similar to byType, but type applies to constructor arguments. If there is not exactly one
bean of the constructor argument type in the container, a fatal error is raised.

Q 83- How bean life cycle can be controlled?

A - Using init() only

B - Using InitializingBean class only

C - Using DisposableBean class only

D - Using All of above


Q 84 - Which of the following class can be used to call Stored Procedures in spring?

A - SPHelper

B - JdbcTemplateCall

C - JdbcTemplate

D - SimpleJdbcCall

Q 85 - Which are the correct implementation classes of ApplicationContext?

A - FileSystemXmlApplicationContext, ClassPathXmlApplicationContext,
WebXmlApplicationContext

B - FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext

C - AdvancedApplicationContext, FileApplicationContext

D - FileSystemApplicationContext, ClassPathApplicationContext

Q 86 - How around advice works?

A - Run advice before and after the advised method is invoked.

B - Run advice before and after a class is loaded.

C - Run advice before and after http response is returned.

D - Run advice before and after http request is processed.

Q 87 - Which of the following is correct assertion about spring?

A - Spring enables developers to develop enterprise-class applications using POJOs.

B - Spring is organized in a modular fashion.

C - Testing an application written with spring is simple because environment-dependent code is


moved into this framework.
D - All of above.

1)Given the following configuration class, what are correct affirmations? Select one or more answers.
public class ApplicationConfig {
private DataSource dataSource;
@Autowired
public ApplicationConfig(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean(name="clientRepository")
ClientRepository jpaClientRepository() {
return new JpaClientRepository();
}
}
1. @Configuration annotation is missing----------ANS
2. Default or no-arg constructor is missing-------ANS
3. @Bean name is ambiguous
4. @Bean scope is prototype
---------------------------------------------------------------------------------------------------------------
2)<id name="deptId" type="string">
<column name="columnid" length="30"/>
<generatoers/>
<id/>
[/xml]

The above is an example of creatinf which key?

Select One:
a.DB key
b.Unique key
c.Secondary key
d.Primary key--------ANS
--------------------------------------------------------------------------------------------------------------------
3)ApplicationContext implements which of the following interface that is used to obtain localized
messages, with the actual implementation being pluggable

I. MessageSource
II. RequestMapping

Select One:
a. only I--------------ANS
b.only II
c. Neither I or II
d. Both I and II
--------------------------------------------------------------------------------------------------------------------
4).Which of the following is a many to one relationship
a) many-to-one
b) <many-to-one>---------ANS
c) None of the list
d) <Manyone>
-------------------------------------------------------------------------------------------------------------
5)What of the following is not correct in live environment?

select one
a. Constuctor and properties autowiring in the same bean are not compatible
b. A bean should have a default or a no-args constructor
c. The <constructor-arg> tag could take type, name and index to reduce ambiguity
d. All of the above-----------ANS(not sure)
--------------------------------------------------------------------------------------------------------------------------
6)Which of the following is not available in HQL
select one
a) Select
b)Where
c)Sub---------------Ans(not sure)
d)Having
--------------------------------------------------------------------------------------------------
7)maven is a project management and comprehension too
select one
True----------Ans
False
-----------------------------------------------------------------------------------------
8)How many layers are there in Hibernate architechture
select one
a)3------------Ans(not sure)
b)4
c)5
d)2
------------------------------------------------------------------------
9)Beans,Core, Context,spEL are the components in Core container
select one
True----------Ans
False
-------------------------------------------------------------------------------------------------------
10) PROPAGATION_REQUIRES_NEW

Ans: Creates a new transaction, suspending the current transaction if one exists.
----------------------------------------------------------------------------------------------------------
11)Element which can be used to inject a collection of name-value pairs where the name and the value
can be of any type.

select one
a)<list>
b)<set>
c)<map>---------------ANS
d)<props>
-----------------------------------------------------------------------------------------------------------------
12)Element which can be used to inject a collection of name-value pairs where the name and the value
are both Strings type.

select one
a)<list>
b)<set>
c)<map>
d)<props>---------------ANS
-----------------------------------------------------------------------------------------
13)which type of annotation applies to bean property setter methods
select one
a)@Requires
b)@Resource
c)@Required----------------ANS
d)@Requiring
----------------------------------------------------------------------------------------------------------------------
14)ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data
between relational databases.
select one
True----------Ans
False
-------------------------------------------------------------------------------------------------------------
15)Which tool helps to generate the mapping document Though many Hibernate users choose to write
the XML by hand
select one
a)oldgen
b)younggen
c)Middlegen----------------ANS
d) Mediumgen
-------------------------------------------------------------------------------------------------------------
16)Java based configuration option disables you to write most of your Spring configuration without XML
but with the help of few Java-based annotations
select one
True
False----------Ans
------------------------------------------------------------------------------------------------------------------------------------------
-
17) What types of views supported by spring MVC for different presentation technologies
select one or more
a)JSP
b)HTML
c)velocity templates
d)

Ans: select all


---------------------------------------------------------------------------------------------------------------------------------
18)Spring is a heavy weight framework
select one
True
False----------Ans
-------------------------------------------------------------------------------------------------------------------------
19)A very powerful and high performance qurerying language used to Query,retrive,store data in DB is
select one
a)PLSQL
b)HQL-------ANS(not sure)
c)SQL
d)RDBMS
----------------------------------------------------------------------------------------
20)which of the following options about Auto wiring in spring are correct?

I. The Auto wiring in spring framework can be performed by configuring in xml and spring Auto-Wiring
with Annotation @Autowired
II. Auto-wiring beans with xml configuration: In Spring framework, you can wire beans automatically
with auto wiring feature
III. To enable auto-wiring just define the "autowire" attribute in <bean> tag.

Select One:
a.I, II, and III--------ANS
b.I and III
c.I and II
d.II and III
----------------------------------------------------------------------------------------------------------------------------------

Topics to read:

* HQL
*Tools in hibernate
*Interceptors in hibernate
*Annotations in both spring and hibernate
*specifications for Java API (eg:JSR-250,JSR-303)
*Interfaces and classes in both spring and hibernate(eg: ViewResolver is a interface)
*Mapping in hibernate(eg: Middlegen is a tool)
Q 1 - What ORM stands for?

A - Object Relation Map

B - Object Relational Mapping

C - Object Record Mapping

D - None of the above.

Q 2 - Which of the following is true about configuration component of Hibernate?

A - The Configuration object is the first Hibernate object you create in any Hibernate application.

B - The Configuration object is usually created only once during application initialization.

C - The Configuration object represents a configuration or properties file required by the Hibernate.

D - All of the above.

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

A - true

B - false

Q 4 - Which element of hbm.xml defines maps the unique ID attribute in class to the primary key of the
database table?

A - id

B - generator

C - primaryKey

D - None of the above.

Q 5 - Which of the following element maps java.util.SortedMap property in hibernate?

A - <set>

B - <list>

C - <bag>
D - <map>

Q 6 - What is lazy loading?

A - Lazy loading is a technique in which objects are loaded on demand basis.

B - Lazy loading is a technique in which objects are persisted on demand basis.

C - Both of the above.

D - None of the above.

Q 7 - What is first level cache in hibernate?

A - The first-level cache is the Session based cache.

B - The first-level cache is the SessionFactory based cache.

C - Both of the above.

D - None of the above.

Q 8 - When a Transactional concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical
concern.

D - None of the above.

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

A - Transaction

B - SessionFactory

C - Session

D - All of the above


Q 10 - Which of the following is true about @GeneratedValue annotation?

A - @GeneratedValue annotation takes two parameters strategy and generator.

B - @GeneratedValue annotation provides the primary key generation strategy to be used.

C - Both of the above.

D - None of the above.

Q 11 - Which of the following is not an ORM framework?

A - Castor

B - Spring DAO

C - Hibernate

D - NoSQL

Q 12 - Which of the following is true about SessionFactory object in hibernate?

A - The SessionFactory is heavyweight object.

B - SessionFactory object is created during application start up and kept for later use.

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

D - All of the above.

Q 13 - Which of the following is true about transient state of a persistent entity?

A - A new instance of a persistent class which is not associated with a Session.

B - A new instance of a persistent class which has no representation in the database.

C - A new instance of a persistent class which has no identifier value.

D - All of the above.

Q 14 - Which method is used to re-read the state of the given instance from the underlying database?
A - Session.refresh()

B - Session.get()

C - Session.reload()

D - Session.retrieve()

Q 15 - Which of the following element maps java.util.List property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 16 - Child objects are not loaded when parent is loaded/populated from database. What this
technique is called?

A - Eager Loading

B - Lazy Loading

C - Request based Loading

D - None of the above.

Q 17 - What HQL stands for?

A - Hibernate Query Language

B - High Query Language

C - Hybrid Query Language

D - None of the above.

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

A - Oracle

B - Microsoft SQL Server Database


C - FoundationDB

D - Informix Dynamic Server

Q1 9 - A Session is used to get a physical connection with a database.

A - true

B - false

Q 20 - Which of the following is true about HQL?

A - Hibernate supports named parameters in its HQL queries.

B - HQL supports a range of aggregate methods, similar to SQL.

C - Both of the above.

D - None of the above.

Q 21 - Which of the following is true about Hibernate?

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

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

C - Both of the above.

D - None of the above.

Q 22 - Which of the following is true about hibernate.dialect property in hibernate configuration?

A - This property makes Hibernate generate the appropriate SQL for the chosen database.

B - This property makes Hibernate generate the appropriate java code for the chosen database.

C - Both of the above.

D - None of the above.

Q 23 - Which method is used to save the state of the given instance from the underlying database?

A - Session.store()
B - Session.keep()

C - Session.save()

D - Session.load()

Q 24 - Which of the following element maps java.util.Map property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 25 - What is Query level cache in hibernate?

A - The query-level cache is cache for query resultsets that integrates closely with the second-level
cache.

B - The query-level cache is the Session based cache.

C - Both of the above.

D - None of the above.

Q 26 - Which of the following is a concurrency strategies in hibernate?

A - Transactional

B - Read-write

C - Nonstrict-read-write.

D - All of the above.

Q 27 - Which of the following is true about @Id annotation?

A - Hibernate detects that the @Id annotation is on a field.

B - Hibernate assumes that it should access properties on an object directly through fields at runtime.
C - Both of the above.

D - None of the above.

Q 28 - Which of the following is true about HQL?

A - HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action
on database.

B - The AS clause can be used to assign aliases to the classes in HQL queries.

C - Both of the above.

D - None of the above.

Q 29 - Which of the following is true about ORM?

A - ORM stands for Object-Relational Mapping.

B - ORM is a programming technique for converting data between relational databases.

C - Both of the above.

D - None of the above.

Q 30 - Which of the following is true about Query object in hibernate?

A - Query objects Hibernate Query Language (HQL) string to retrieve data from the database and create
objects.

B - Query objects SQL string to retrieve data from the database and create objects.

C - A Query instance is used to bind query parameters, limit the number of results returned by the
query, and finally to execute the query.

D - All of the above.

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

A - true

B - false
Q 32 - Which method is used to get a persistent instance from the datastore?

A - Session.read()

B - Session.get()

C - Session.retrieve()

D - Session.fetch()

Q 33 - Which of the following is true about <generator> element?

A - The <generator> element within the id element is used to automatically generate the primary key
values

B - Set the class attribute of the generator element is set to native to let hibernate pick up either
identity, sequence or hilo algorithm to create primary key depending upon the capabilities of the
underlying database.

C - Both of the above.

D - None of the above.

Q 34- Which of the following element is used to represent one-to-many relationship in hibernate?

A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

Q 35- Is query level caching mandatory in hibernate?

A - true

B - false

Q 36 - When a Read-only concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical
concern.

D - None of the above.

Q 37 - Which of the following is true about hibernate annotations?

A - Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational
Table mapping.

B - 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.

C - Both of the above.

D - None of the above.

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

A - JDBC

B - SessionFactory

C - Session

D - Configuration

Q 39 - Is Session a thread-safe object?

A - true

B - false

Q 40 - Which method is used to remove a persistent instance from the datastore?

A - Session.delete()

B - Session.remove()

C - Session.del()

D - Session.rm()
Q 41- Which method is used to save or update the state of the given instance from the underlying
database?

A - Session.saveOrUpdate()

B - Session.keep()

C - Session.update()

D - Session.load()

Q 42 - Is first level caching mandatory in hibernate?

A - true

B - false

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

A - DB2/NT

B - PostgreSQL

C - Sybase SQL Server

D - All of the above

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

A - true

B - false

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

A - true

B - false

Q 46- Which of the following is true about Transaction object in hibernate?


A - A Transaction represents a unit of work with the database.

B - Transactions in Hibernate are handled by an underlying transaction manager.

C - This is an optional object and Hibernate applications may choose not to use this interface, instead
managing transactions in their own application code.

D - All of the above

Q 47 - Session.beginTransaction method begins a unit of work and returns the associated Transaction
object.

A - true

B - false

Q 48 - Which element of hbm.xml automatically generate the primary key values?

A - id

B - generator

C - primaryKey

D - None of the above.

Q 49- What is the difference between get() and load() methods of session object?

A - get() returns null if no data is present where as load throws ObjectNotFoundException exception in
such case.

B - get() always hits the database whereas load() method doesn't hit the database.

C - get() returns actual object whereas load() returns proxy object.

D - All of the above.

Q 50 - The SessionFactory is heavyweight object.

A - false

B - true

Q 51 - Which of the following is true about HQL?


A - Hibernate Query Language (HQL) is an object-oriented query language.

B - Instead of operating on tables and columns, HQL works with persistent objects and their properties.

C - Both of the above.

D - None of the above.

Q 52 - Which of the following is true about SessionFactory object in hibernate?

A - The SessionFactory is heavyweight object.

B - SessionFactory object is created during application start up and kept for later use.

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

D - All of the above.

Q 53 - Which of the following situation represents many-to-many relationship?

A - An employee can have multiple certificates and same certificate can be conferred to many
employees.

B - An employee can have multiple certificates.

C - A certificate can be conferred to many employees.

D - All of the above.

Q 54- What is second level cache in hibernate?

A - The second-level cache is the SessionFactory based cache and is mainly responsible for caching
objects across sessions.

B - The second-level cache is the Session based cache.

C - Both of the above.

D - None of the above.

Q 55 - Which of the following is true about @Column annotation?

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

B - The @Column annotation is applied on a class.

C - Both of the above.

D - None of the above.

Q 56 - Which of the following object is used to create SessionFactory object in hibernate?

A - Configuration

B - Session

C - SessionFactory

D - Transaction

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

A - true

B - false

Q 58 - Which of the following is true about <id> element?

A - The <id> element maps the unique ID attribute in class to the primary key of the database table.

B - The name attribute of the id element refers to the property in the class.

C - The column attribute of the id element refers to the column in the database table.

D - All of the above.

Q 59 - Is second level caching mandatory in hibernate?

A - true

B - false

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

A - Transaction
B - SessionFactory

C - Session

D - All of the above

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

A - true

B - false

Q 62 - Which of the following is true about <property> element?

A - The <property> element is used to map a Java class property to a column in the database table.

B - The name attribute of the element refers to the property in the class.

C - The column attribute of the element refers to the column in the database table.

D - All of the above.

Q 63 - Which of the following is true about @Entity annotation?

A - @Entity annotation marks a class as an entity bean.

B - Class marked with @Entity annotation must have a no-argument constructor that is visible with at
least protected scope.

C - Both of the above.

D - None of the above.

Q 64 - Which of the following is true about Hibernate?

A - Hibernate takes care of mapping Java classes to database tables using XML files and without writing
any line of code.

B - Hibernate provides simple APIs for storing and retrieving Java objects directly to and from the
database.

C - Hibernate abstracts away the unfamiliar SQL types and provide us to work around familiar Java
Objects.
D - All of the above.

Q 65 - Session.beginTransaction method begins a unit of work and returns the associated Transaction
object.

A - true

B - false

Q 66 - Which element of hbm.xml is used to map a Java class property to a column in the database
table?

A - id

B - generator

C - property

D - class

Q 67 - When a Read-write concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical
concern.

D - None of the above.

Q 68 - Which of the following is true about <class> element?

A - The <class> elements are used to define specific mappings from a Java classes to the database tables.

B - The Java class name is specified using the name attribute of the class element.

C - The database table name is specified using the table attribute of the class element.

D - All of the above.


Q 69- Which of the following tools/frameworks provides integration with Hibernate?

A - XDoclet Spring

B - J2EE

C - Maven

D - All of the above.

Q 70 - Which of the following element maps java.util.Collection property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 71 - Which of the following is true about INSERT CLAUSE in HQL?

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

B - HQL supports INSERT INTO clause without any restriction.

C - Both of the above.

D - None of the above.

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

A - hibernate-mapping

B - hibernate-config

C - class-mapping

D - class-config
1.The central artifact in spring javaConfig is the @Configuration-annotated class. ans: true

2.What are the modules of spring web flow?

a. Spring-faces

b. Spring-bundling

c. Spring-container

d.Spring-webflow

3.XML mapping file offers which of the following?????????????????

4.In spring MVC each tag provides support to the set of attributes of its corresponding HTML
tag counterpart making the tags familiar & intuitive to use. State true or False. true

5.Which of the following are mandatory rules to create validation for a normal employee table?

a. The "empNum" can’t be empty

b."Name" can’t be empty

c. The "empNum" can’t be less than 1

d.All of the option

6.Which of the following allows as to add a new method or attributes to existing classes?

a. Introduction

b. Proxy

c. Weaving

d.Auto call

7.Given the following Spring configuration file, what is the correct answer:

<bean class="com.spring.service.MyServiceImpl">

<property name="repository" ref="jpaDao"/>

</bean>
<bean class="com.spring.repository.JpaDao"/>

a. The first declared bean MyServiceImpl is missing an id must be named myService

b. The second declared bean JpaDao is missing an id must be named jpaDao

c. Answers 1 and 2 are both rights

d. Answers 1 and 2 are both wrong

8.Which of the following are the best practices for writing spring XML configuration?

a. Rarely use classpath.

b. Mentioning version numbers in schema reference

c. Using consistent naming conventions

d. Reuse bean definitions as much as possible

-----------------------------------------------------------------------------------------------------------------

best practices:

1) Add a header comment to each configuration file

2) Use consistent naming conventions

3) No version numbers in schema references

4) Prefer setter injection over constructor injection

5) Prefer type over index for constructor argument matching

6) Use shortcut forms over expanded forms

7) Reuse bean definitions as much as possible

8) Always use ids as bean identifiers

9) Try to avoid autowiring

10) Always use classpath prefix

11) Always externalize properties

12) Use dependency-check at the development phase

13) Do not abuse/overuse dependency injection

9.Spring MVC provides better way to separate which of the following?


a. Presentation

b. Tools

c. Data Access

d. Business Logic

(business logic, UI login, /P logic)

10.We can use index and type attribute together. State true or False. -true

11.which of the following is Hibernate?

a. Lightweight

b. Open Source

c. ORM

d.All of the listed

12.Which of the following options about Auto Wiring in spring are correct?

1.Auto-wiring in spring framework can be performed by configuring xml and auto-wiring with
annotation @Autowired.

2.Auto-wiring beans with xml configuration: In spring framework, you can wire automatically
with auto-wiring feature.

3.To enable auto-wiring just define the "autowire" attribute in <bean> tag.

13.Which of the following parses in xml based on expression and its used extensively in
conjunction with XLST?

a. Xpath parser ----------Ans

b. SAX parser

c. STAX Parser

d. JDOM Parser

14.Length attribute of @column annotation permits the size of the column used to map a value
particularly for a string value. State true or False. -----true
15.When we work with an object oriented system there's a mismatch between the object modal
and the relational database. State true or False. -----true

16.Which of the following is true about JDBC?

a. JDBC APIs enables java programs to execute SQL statements and interact with any SQL
Complaint database

b. JDBC stands for Java Database Connectivity

c.it provides set of java API for accessing the relational databases from java program

d.All the listed option -----------Ans

17.- What is session scope?

A - This scopes a bean definition to an HTTP session.

B - This scopes the bean definition to Spring IoC container.

C - This scopes the bean definition to HTTP request.

D - This scopes the bean definition to HTTP Application/ Global session

18.Which of the listed statement are correct for spring Bean scope: Prototype?

1.Spring container creates new instance of bean for each and every request for that bean

2.Prototype scoped bean is served by creating new instance of bean for each and every bean
dependency

3.After instantiating bean and submitting it to client spring container will maintain the record
(not maintain)

4.Prototype scope is spring standard scope and can be used in standalone as well as web
application of spring.

19.ServletWrappingController-Wraps an existing servlet which is managed completely by the


spring environment. State true or False. ---------true

20.Hibernate session is the main runtime interface between a java application and Hibernate.
State true or False. -----true
23.Which of the following are correct in sql queries in hibernate.

1.sql queries may contain named and positional parameters, just like hibernate queries

2.You may express a query in sql using createSQLQuery()

3. Hibernate take care of the mapping from result sets to objects

4.You may call session.connection() and use JDBC Connection at any time

24.Which is the query language that embodies a very powerful and flexible mechanism to
query, store, update and retrieve objects from a database?

a. PLSQL

b. RDBMS

c. SQL

d. HQL

25.What is spring MVC framework?

a. spring MVC framework is used for Transaction management for web application

b. spring MVC framework is Model-value-class architecture and used to bind model data

c. spring MVC framework is used for AOP for web application

d. spring web MVC framework provides model-view-controller architecture and ready


components that can be used to develop flexible and loosely coupled web applications.

26.Which of the listed options are True for bean configuration inheritance?

1.In spring the inheritance is supported in bean to share common values properties or
configurations 2.A child bean or inherited bean can inherit its parent bean configurations,
properties & some attributes 3. the parent bean allows to override the inherited values.

27.XsltViewResolver-supports XsltView by resolving the view name of which of the following


options?

a. View name of the URL of the report file

b.URL of the XSLT---Ans


c. VelocityView and its subclasses

d.All of the option

28.[xml]

<id name="deptId" type="string">

<column name="columnId" length="30"/>

<generator/>

</id>

[xml]

The above is an example of creating which key?

a. Primary key -------------------Ans

b. Secondary key

c. Unique key

29.When you need to upload a large number of records into your database using Hibernate, you
can use batch processing. State true or False. ---true

30.Different types of run advice "before" and "after" the advised method is invoked. Which of
the following is the correct option with respect to advice?

a. After returning

b. None

c. After throwing

d. around -----ANs

31.Implementation of viewResolver accepts a configuration file written in XML with the same
DTD as spring XML bean factories. State true or False. ---------true

32.Choose the odd one out respect to annotations from the following

a.@requestmapping
b. @controller

c.@responsevalid

d.@Pathvalid

33.For a fast Development, the dependency injection feature of spring Framework & support to
various Frameworks makes the easy development of javaEE application. state true or False. -----
true

34.Testing an application written with Spring is complex because environment-dependent

code is moved into this framework. state true or False. --false (simple)

35.The application is designed around an object model. Sql code is generated at build time

& the associations between obj are supported by the persistence mechanism, and queries are

specified using an obj-oriented expression language. This is best suited for medium-sized
applications

with some complex transactions. Used when mapping exceeds 25 different database products at
a time.

which of the following is this called as?

a. Object mapping

b. Application object mapping

c. Medium object mapping-------------------Ans

d. Expression object mapping

36.Which of the following is not the steps for creating web MVC?

a. Provide exit controller in the web

b. Create a controller class

c. start server & deploy the project-----Ans

d. Define the bean in the xml file

37.Maven is a project management &comprehension tool. state true or False. True


38.Which of the following elements is used to represent one-to-one relationship in hibernate?

a. <many-to-one>

b. <ManyToOne>

c. <many-one>

d. none

The <many-to-one> element will be used to define the rule to establish a one-to-one relationship
between EMPLOYEE and ADDRESS entities, but column attribute will be set to unique
constraint and rest of the mapping file will remain as it was in case of many-to-one association.

OR

61.Which of the following is a one to one relationship

a) <many-to-many>

b) <many-to-one>

c) None of the list---------ANS

d) <one-to-many>

39.In hibernate implement cache for a query, if the result sets can integrate closely, which level

of the cache can be implemented?

a. first level cache

b. second level cache-------Ans

c. third level cache

d. Fourth level cache

40.Spring MVC provides predefined templates for JDBC, Hibernate and JPA. state true or False.
----true

41.In Spring MVC which of the following is the front controller class that initializes the context

based on the spring beans configuration?

a. org.springframework.web.servlet.DispatcherServlet
b. org.springframework.web.context.DispatcherServlet

c. org.springframework.web.servlet

d. org.springframework.web.context.ApplicationContext

42.Which of the following is NOT the type of mapping?

a. Instance mapping-------------Ans

b. Component mapping

c. Association mapping

d. Class mapping

43.Which of the following are modules of Web layer?

A - WebSocket, Servlet, Web, Portlet-----ANs

B - WebSocket, Servlet, Web-MVC, Web

C - HTML, JSP, WEB, Portlet

D - HTML, Servlet, WEB, Portlet

44.Which of the following statements are correct?

a. Bean Factory and ApplicationContext are basic container only

b. Bean Factory is basic container and ApplicationContext is advanced container---ANs

c. Bean Factory and ApplicationContext are advanced container

d. Bean Factory is advanced container and ApplicationContext is basic container

45.In spring bean configuration bean attribute called 'scope' defines what kind of object

has to be created and returned. What returns a new bean instance each time when required?

a. Prototype----Ans

b. Session

c. Singleton

d. Global session
46.To validate the form fields you need to have a separate UserValidator class

that implements the validator interface, override the validate () method perform all the
validations. state true or False. ------true

47.The application context implements which of the following interface that is used to obtain
localized

messages, with the actual implementation being pluggable?

1.messageSource -------------------Ans

2.RequestMapping

3.both

4.neither

48.Which of the following is an available aggregate function in HQL?

a. Aggregate (property name)

b. Count (property name or *)

c. max (property name)

d. avg (property name)

49.What statement is not correct in live environment? Select a unique answer.

1. Constructor and properties autowiring in the same bean are not compatible

2. A bean should have a default or a no-args constructor

3. The <constructor-arg> tag could take type, name and index to reduce ambiguity

4. None of the above

5. All of the above

50.- What is ContextClosedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.


C - This event is published when the HTTP Response is returned.

D - This event is published when the ApplicationContext is closed using the close method on
the

ConfigurableApplicationContext interface. --------ANs

51.Which of the following explains about addclass() function in the listed options?

a. this function translates a java class name into file name------------------------------ANs

b. this translated file name is then loaded as an input stream from the java class loader--ANs

c. this addclass() function is important if you want efficient usage of classes in your code---------
-Ans

52.Spring MVC provides a JSP tag library (Spring form) for making it easier to bind form
elements to model data. state true or False. Ans:True

53.Which of the following is correct assertion about spring?

a. Spring enables developers to develop enterprise-class applications using POJOs.

b. Spring is organized in a modular fashion.

c. Testing an application written with spring is simple because environment-dependent code is


moved into this framework.

d.All of above.

54.Which of the following statement is INCORRECT by extending ViewResolver and


ChainingViewResolver?

a. programmers can have custom view resolvers

b. There are lot of view resolvers available in Spring framework

c. Spring MVC view resolvers help the Dispatcher Servlet in identifying the views which has to
be rendered in response for a request.

d. none

55.What are the benefits of Spring Framework's transaction management?

a. It Provides a consistent programming model across different transaction APIs such as JTA,
JDBC, Hibernate, JPA, and JDO.
B. It Supports declarative transaction management.

c. It Provides a simpler API for programmatic transaction management than a number of


complex transaction APIs such as JTA.

d.All the listed

56.Given the following configuration class, what are correct affirmations? Select one or more
answers.

public class ApplicationConfig {

private DataSource dataSource;

@Autowired

public ApplicationConfig(DataSource dataSource) {

this.dataSource = dataSource;

@Bean(name="clientRepository")

ClientRepository jpaClientRepository() {

return new JpaClientRepository();

1. @Configuration annotation is missing

2. Default or no-arg constructor is missing

3. @Bean name is ambiguous

4. @Bean scope is prototype

57.What is true about <list> collection configuration elements?

A. This helps in wiring a list of values, allowing duplicates. ----------<list>

B.Ths. helps in wiring a list of values but without any duplicates. -----<set>

C. This can be used to inject a collection of name-value pairs where name and value can be of

any type. --------<map>

This can be used to inject a collection of name-value pairs where the name and value are
both Strings. ----------<props>

Ans: This helps in wiring a list of values, allowing duplicates.

58.Which are the correct implementation classes of ApplicationContext?

A. FileSystemXmlApplicationContext,ClassPathXmlApplicationContext,

WebXmlApplicationContext-------------

B. FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext

C.AdvancedApplicationContext, FileApplicationContext

D.FileSystemApplicationContext, ClassPathApplicationContext

59.It is difficult to inject the dependency by constructor. state true or False. ---true

60.The Model-View-Controller(MVC) is an architectural pattern that does not separate an


application into three main logical components: the model, the view and the controller.

state true or False. -------false


Q1-WhatORM st
andsf
or?

A-Obj
ectRel
ati
onMap

B-Obj
ectRel
ati
onal
Mappi
ng

C-Obj
ectRecor
dMappi
ng

D-Noneoft
heabov
e.

Q2-Whi
choft
hef
oll
owi
ngi
str
ueaboutconf
igur
ati
oncomponentofHi
ber
nat
e?

A-TheConfi
gur
ati
onobj
ecti
sthef
ir
stHi
ber
nat
eobj
ecty
oucr
eat
einanyHi
ber
nat
e
appl
i
cat
ion.

B-TheConfi
gur
ati
onobj
ecti
susual
l
ycr
eat
edonl
yoncedur
ingappl
i
cat
ion
i
nit
ial
i
zat
ion.

C-TheConf
igur
ati
onobj
ectr
epr
esent
saconf
igur
ati
onorpr
oper
ti
esf
il
erequi
redby
t
heHiber
nat
e.

D-Al
loft
heabov
e.

Q3-Sessi
on.
creat
eQuer
ycr
eat
esanewi
nst
anceofQuer
yfort
hegi
venHQLquer
y
st
ri
ng.

A-t
rue

B-f
alse

Q4-Whichel
ementofhbm.x
mldefi
nesmapst
heuni
queI
Dat
tri
but
eincl
asst
othe
pr
imar
ykeyofthedat
abaset
abl
e?

A-i
d

B-gener
ator

C-pr
imar
yKey

D-Noneoft
heabov
e.

Q5-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Sor
tedMappr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>

C-<bag>

D-<map>
Q6-Whati
slaz
yloadi
ng?

A-Lazyl
oadi
ngi
sat
echni
quei
nwhi
chobj
ect
sar
eloadedondemandbasi
s.

B-Lazyl
oadi
ngi
sat
echni
quei
nwhi
chobj
ect
sar
eper
sist
edondemandbasi
s.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q7-Whati
sfi
rstl
evel
cachei
nhi
ber
nat
e?

A-Thef
ir
st-
lev
elcachei
stheSessi
onbasedcache.

B-Thef
ir
st-
lev
elcachei
stheSessi
onFact
orybasedcache.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q8-WhenaTr
ansact
ional
concur
rencyst
rat
egyi
stobeused?

A-Usei
tforr
efer
encedat
aonl
y.

B-Uset hi
sstrat
egyforr
ead-
most
lydat
awher
eiti
scr
it
ical
topr
eventst
aledat
ain
concur
renttr
ansact
ions.

C-Usethisstr
ategyi
fdat
ahar
dlyev
erchangesandasmal
ll
ikel
i
hoodofst
aledat
ais
notofcr
it
ical
concern.

D-Noneoft
heabov
e.

Q9-Whi
choft
hef
oll
owi
ngi
sacor
ecomponentofHi
ber
nat
e?

A-Tr
ansact
ion

B-Sessi
onFact
ory

C-Sessi
on

D-Al
loft
heabov
e

Q10-Whi
choft
hef
oll
owi
ngi
str
ueabout@Gener
atedVal
ueannot
ati
on?

A-@Gener
atedVal
ueannot
ati
ont
akest
wopar
amet
ersst
rat
egyandgener
ator
.

B-@Gener
atedVal
ueannot
ati
onpr
ovi
dest
hepr
imar
ykeygener
ati
onst
rat
egyt
obe
used.
C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q11-Whi
choft
hef
oll
owi
ngi
snotanORM f
ramewor
k?

A-Cast
or

B-Spr
ingDAO

C-Hi
ber
nat
e

D-NoSQL

Q12-Whi
choft
hef
oll
owi
ngi
str
ueaboutSessi
onFact
oryobj
ecti
nhi
ber
nat
e?

A-TheSessi
onFact
oryi
sheav
ywei
ghtobj
ect
.

B-Sessi
onFact
oryobj
ecti
scr
eat
eddur
ingappl
i
cat
ionst
artupandkeptf
orl
ateruse.

C-YouwouldneedoneSessi
onFact
oryobj
ectperdat
abaseusi
ngasepar
ate
conf
igur
ati
onf
il
e.

D-Al
loft
heabov
e.

Q13-Whi
choft
hef
oll
owi
ngi
str
ueaboutt
ransi
entst
ateofaper
sist
entent
it
y?

A-Anewi
nst
anceofaper
sist
entcl
asswhi
chi
snotassoci
atedwi
thaSessi
on.

B-Anewi
nst
anceofaper
sist
entcl
asswhi
chhasnor
epr
esent
ati
oni
nthedat
abase.

C-Anewi
nst
anceofaper
sist
entcl
asswhi
chhasnoi
dent
if
ierv
alue.

D-Al
loft
heabov
e.

Q14-Whi chmet
hodisusedt
ore-
readt
hest
ateoft
hegi
veni
nst
ancef
rom t
he
under
lyi
ngdat
abase?

A-Sessi
on.
ref
resh(
)

B-Sessi
on.
get
()

C-Sessi
on.
rel
oad(
)

D-Sessi
on.
ret
ri
eve(
)

Q15-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Li
stpr
oper
tyi
nhi
ber
nat
e?
A-<set
>

B-<l
i
st>

C-<bag>

D-<map>

Q16-Chil
dobj ectsarenotloadedwhenpar
enti
sloaded/
popul
atedf
rom dat
abase.
Whatt
histechniqueiscall
ed?

A-EagerLoadi
ng

B-LazyLoadi
ng

C-RequestbasedLoadi
ng

D-Noneoft
heabov
e.

Q17-WhatHQLst
andsf
or?

A-Hi
ber
nat
eQuer
yLanguage

B-Hi
ghQuer
yLanguage

C-Hy
bri
dQuer
yLanguage

D-Noneoft
heabov
e.

Q18-Whi
choft
hef
oll
owi
ngdat
abasei
snotsuppor
tedbyHi
ber
nat
e?

A-Or
acl
e

B-Mi
crosof
tSQLSer
verDat
abase

C-Foundat
ionDB

D-I
nfor
mixDy
nami
cSer
ver

Q19-ASessi
oni
susedt
ogetaphy
sical
connect
ionwi
thadat
abase.

A-t
rue

B-f
alse

Q20-Whi
choft
hef
oll
owi
ngi
str
ueaboutHQL?

A-Hi
ber
nat
esuppor
tsnamedpar
amet
ersi
nit
sHQLquer
ies.

B-HQLsuppor
tsar
angeofaggr
egat
emet
hods,
simi
l
art
oSQL.
C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q21-Whi
choft
hef
oll
owi
ngi
str
ueaboutHi
ber
nat
e?

A-Hi
ber
nat
eisanObj
ect
-Rel
ati
onal
Mappi
ng(
ORM)sol
uti
onf
orJAVA.

B-Hi
ber
nat
eisanObj
ect
-Rel
ati
onal
Mappi
ng(
ORM)sol
uti
onf
or.
NET

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q22-Whi chofthef
oll
owi
ngi
str
ueabouthi
ber
nat
e.di
alectpr
oper
tyi
nhi
ber
nat
e
conf
igur
ation?

A-Thispr
oper
tymakesHi
ber
nat
egener
atet
heappr
opr
iat
eSQLf
ort
hechosen
dat
abase.

B-Thi
sproper
tymakesHi
ber
nat
egener
atet
heappr
opr
iat
ejav
acodef
ort
hechosen
dat
abase.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q23-Whi chmet
hodisusedt
osav
ethest
ateoft
hegi
veni
nst
ancef
rom t
he
under
lyi
ngdat
abase?

A-Sessi
on.
stor
e()

B-Sessi
on.
keep(
)

C-Sessi
on.
sav
e()

D-Sessi
on.
load(
)

Q24-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Mappr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>

C-<bag>

D-<map>
Q25-Whati
sQuer
ylev
elcachei
nhi
ber
nat
e?

A-Thequer y
-l
evelcachei
scachef
orquer
yresul
tset
sthati
ntegr
atescl
osel
ywi
tht
he
second-
lev
elcache.

B-Thequer
y-l
evel
cachei
stheSessi
onbasedcache.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q26-Whi
choft
hef
oll
owi
ngi
saconcur
rencyst
rat
egi
esi
nhi
ber
nat
e?

A-Tr
ansact
ional

B-Read-
wri
te

C-Nonst
ri
ct-
read-
wri
te.

D-Al
loft
heabov
e.

Q27-Whi
choft
hef
oll
owi
ngi
str
ueabout@I
dannot
ati
on?

A-Hi
ber
nat
edet
ect
sthatt
he@I
dannot
ati
oni
sonaf
iel
d.

B-Hiber
nateassumest
hati
tshoul
daccesspr
oper
ti
esonanobj
ectdi
rect
lyt
hrough
f
iel
dsatrunt
ime.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q28-Whi
choft
hef
oll
owi
ngi
str
ueaboutHQL?

A-HQLqueri
esaretr
ansl
atedbyHiber
nat
eint
oconv
ent
ional
SQLquer
ieswhi
chi
n
t
urnsper
for
m act
ionondatabase.

B-TheAScl
ausecanbeusedt
oassi
gnal
i
asest
othecl
assesi
nHQLquer
ies.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q29-Whi
choft
hef
oll
owi
ngi
str
ueaboutORM?

A-ORM st
andsf
orObj
ect
-Rel
ati
onal
Mappi
ng.

B-ORM isapr
ogr
ammi
ngt
echni
quef
orconv
ert
ingdat
abet
weenr
elat
ional
dat
abases.
C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q30-Whi
choft
hef
oll
owi
ngi
str
ueaboutQuer
yobj
ecti
nhi
ber
nat
e?

A-Queryobj
ect
sHiber
nateQuer
yLanguage(
HQL)st
ri
ngt
oret
ri
evedat
afr
om t
he
dat
abaseandcr
eat
eobjects.

B-Quer
yobj
ect
sSQLst
ri
ngt
oret
ri
evedat
afr
om t
hedat
abaseandcr
eat
eobj
ect
s.

C-AQueryi
nst
anceisusedtobindquerypar
ameter
s,l
imi
tthenumberofr
esul
ts
r
etur
nedbyt
hequery
, andf
inal
l
yt oexecut
ethequer
y.

D-Al
loft
heabov
e.

Q31-Sessi
on.
creat
eSQLQuer
ycr
eat
esanewi
nst
anceofQuer
yfort
hegi
venSQL
quer
yst
ri
ng.

A-t
rue

B-f
alse

Q32-Whi
chmet
hodi
susedt
ogetaper
sist
enti
nst
ancef
rom t
hedat
ast
ore?

A-Sessi
on.
read(
)

B-Sessi
on.
get
()

C-Sessi
on.
ret
ri
eve(
)

D-Sessi
on.
fet
ch(
)

Q33-Whi
choft
hef
oll
owi
ngi
str
ueabout<gener
ator
>el
ement
?

A-The<gener
ator
>el
ementwi
thi
nthei
del
ementi
susedt
oaut
omat
ical
l
ygener
ate
t
hepri
marykeyval
ues

B-Settheclassattr
ibuteoft
hegenerat
orel ementissett
onati
vetolethi
ber
nate
pi
ckupeitheridenti
ty,
sequenceorhi
loalgorit
hm tocreat
epr
imarykeydependi
ng
uponthecapabili
ti
esoftheunderl
yi
ngdat abase.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q34-Whi
choft
hef
oll
owi
ngel
ementi
susedt
orepr
esentone-
to-
manyr
elat
ionshi
pin
hi
ber
nat
e?
A-<one-
to-
many
>

B-<one-
many
>

C-<OneToMany
>

D-Noneoft
heabov
e.

Q35-I
squer
ylev
elcachi
ngmandat
oryi
nhi
ber
nat
e?

A-t
rue

B-f
alse

Q36-WhenaRead-
onl
yconcur
rencyst
rat
egyi
stobeused?

A-Usei
tforr
efer
encedat
aonl
y.

B-Uset hi
sstrat
egyforr
ead-
most
lydat
awher
eiti
scr
it
ical
topr
eventst
aledat
ain
concur
renttr
ansact
ions.

C-Usethisstr
ategyi
fdat
ahar
dlyev
erchangesandasmal
ll
ikel
i
hoodofst
aledat
ais
notofcr
it
ical
concern.

D-Noneoft
heabov
e.

Q37-Whi
choft
hef
oll
owi
ngi
str
ueabouthi
ber
nat
eannot
ati
ons?

A-HibernateAnnot
ati
onsi
sthepower
ful
wayt
opr
ovi
det
hemet
adat
afort
heObj
ect
andRelati
onalTabl
emappi
ng.

B-Allthemetadat
aiscl
ubbedint
ot hePOJOjav
afi
lealongwi t
hthecodethi
shel
ps
theusertounder
standt
hetabl
estructur
eandPOJOsimultaneousl
yduri
ngthe
devel
opment.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q38-Whi
choft
hef
oll
owi
ngi
snotacor
ecomponentofHi
ber
nat
e?

A-JDBC

B-Sessi
onFact
ory

C-Sessi
on

D-Conf
igur
ati
on
Q39-I
sSessi
onat
hread-
saf
eobj
ect
?

A-t
rue

B-f
alse

Q40-Whi
chmet
hodi
susedt
oremov
eaper
sist
enti
nst
ancef
rom t
hedat
ast
ore?

A-Sessi
on.
del
ete(
)

B-Sessi
on.
remov
e()

C-Sessi
on.
del
()

D-Sessi
on.
rm(
)

Q41-Whi
chmet hodisusedt
osav
eorupdat
ethest
ateoft
hegi
veni
nst
ancef
rom
t
heunder
lyi
ngdatabase?

A-Sessi
on.
sav
eOr
Updat
e()

B-Sessi
on.
keep(
)

C-Sessi
on.
updat
e()

D-Sessi
on.
load(
)

Q42-I
sfi
rstl
evel
cachi
ngmandat
oryi
nhi
ber
nat
e?

A-t
rue

B-f
alse

Q43-Whi
choft
hef
oll
owi
ngdat
abasei
ssuppor
tedbyHi
ber
nat
e?

A-DB2/
NT

B-Post
greSQL

C-Sy
baseSQLSer
ver

D-Al
loft
heabov
e

Q44-Conf
igur
ati
onobj
ecti
susedt
ocr
eat
eSessi
onFact
oryobj
ecti
nhi
ber
nat
e.

A-t
rue

B-f
alse
Q45-nameat tr
ibut
eof@Col
umnannot
ati
onper
mit
sthenameoft
hecol
umnt
obe
expl
i
cit
lyspeci
fi
ed.

A-t
rue

B-f
alse

Q46-Whi
choft
hef
oll
owi
ngi
str
ueaboutTr
ansact
ionobj
ecti
nhi
ber
nat
e?

A-ATr
ansact
ionr
epr
esent
sauni
tofwor
kwi
tht
hedat
abase.

B-Tr
ansact
ionsi
nHi
ber
nat
ear
ehandl
edbyanunder
lyi
ngt
ransact
ionmanager
.

C-Thisisanopt
ional
obj
ectandHibernat
eappl
icat
ionsmaychoosenott
ouset
his
i
nter
face,i
nst
eadmanagi
ngtransact
ionsi
nthei
rownappli
cat
ioncode.

D-Al
loft
heabov
e

Q47-Session.
beginTr
ansacti
onmet
hodbegi
nsauni
tofwor
kandr
etur
nst
he
associ
atedTr
ansacti
onobject
.

A-t
rue

B-f
alse

Q48-Whi
chel
ementofhbm.
xml
aut
omat
ical
l
ygener
atet
hepr
imar
ykeyv
alues?

A-i
d

B-gener
ator

C-pr
imar
yKey

D-Noneoft
heabov
e.

Q49-Whati
sthedi
ff
erencebet
weenget
()andl
oad(
)met
hodsofsessi
onobj
ect
?

A-get
()r
eturnsnul
lifnodat
ai spresentwhereasloadt
hrows
Obj
ect
NotFoundExcepti
onexcepti
oni nsuchcase.

B-get
()al
way
shi
tst
hedat
abasewher
easl
oad(
)met
hoddoesn'
thi
tthedat
abase.

C-get
()r
etur
nsact
ual
obj
ectwher
easl
oad(
)ret
urnspr
oxyobj
ect
.

D-Al
loft
heabov
e.

Q50-TheSessi
onFact
oryi
sheav
ywei
ghtobj
ect
.
A-f
alse

B-t
rue

Q51-Whi
choft
hef
oll
owi
ngi
str
ueaboutHQL?

A-Hi
ber
nat
eQuer
yLanguage(
HQL)i
sanobj
ect
-or
ient
edquer
ylanguage.

B-Insteadofoperat
ingont
abl
esandcol
umns,
HQLwor
kswi
thper
sist
entobj
ect
s
andtheirpr
opert
ies.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q52-Whi
choft
hef
oll
owi
ngi
str
ueaboutSessi
onFact
oryobj
ecti
nhi
ber
nat
e?

A-TheSessi
onFact
oryi
sheav
ywei
ghtobj
ect
.

B-Sessi
onFact
oryobj
ecti
scr
eat
eddur
ingappl
i
cat
ionst
artupandkeptf
orl
ateruse.

C-YouwouldneedoneSessi
onFact
oryobj
ectperdat
abaseusi
ngasepar
ate
conf
igur
ati
onf
il
e.

D-Al
loft
heabov
e.

Q53-Whi
choft
hef
oll
owi
ngsi
tuat
ionr
epr
esent
smany
-to-
manyr
elat
ionshi
p?

A-Anempl
oyeecanhav
emul
ti
plecer
ti
fi
cat
esandsamecer
ti
fi
cat
ecanbeconf
err
ed
t
omanyemployees.

B-Anempl
oyeecanhav
emul
ti
plecer
ti
fi
cat
es.

C-Acer
ti
fi
cat
ecanbeconf
err
edt
omanyempl
oyees.

D-Al
loft
heabov
e.

Q54-Whati
ssecondl
evel
cachei
nhi
ber
nat
e?

A-Thesecond-
lev
elcacheist
heSessi
onFactor
ybasedcacheandi
smai
nly
r
esponsi
blef
orcachi
ngobject
sacr
osssessions.

B-Thesecond-
lev
elcachei
stheSessi
onbasedcache.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q55-Whi
choft
hef
oll
owi
ngi
str
ueabout@Col
umnannot
ati
on?
A-The@Columnannot
ati
onisusedt
ospeci
fyt
hedet
ail
soft
hecol
umnt
owhi
cha
f
iel
dorpr
opert
ywil
lbemapped.

B-The@Col
umnannot
ati
oni
sappl
i
edonacl
ass.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q56-Whichoft
hef
oll
owi
ngobj
ecti
susedt
ocr
eat
eSessi
onFact
oryobj
ecti
n
hi
ber
nat
e?

A-Conf
igur
ati
on

B-Sessi
on

C-Sessi
onFact
ory

D-Tr
ansact
ion

Q57-Sessi
on.
creat
eQuer
ycr
eat
esanewi
nst
anceofQuer
yfort
hegi
venHQLquer
y
st
ri
ng.

A-t
rue

B-f
alse

Q58-Whi
choft
hef
oll
owi
ngi
str
ueabout<i
d>el
ement
?

A-The<id>el
ementmapst
heuni
queI
Dat
tri
but
eincl
asst
othepr
imar
ykeyoft
he
dat
abasetabl
e.

B-Thenameat
tri
but
eoft
hei
del
ementr
efer
stot
hepr
oper
tyi
nthecl
ass.

C-Thecol
umnat
tri
but
eoft
hei
del
ementr
efer
stot
hecol
umni
nthedat
abaset
abl
e.

D-Al
loft
heabov
e.

Q59-I
ssecondl
evel
cachi
ngmandat
oryi
nhi
ber
nat
e?

A-t
rue

B-f
alse

Q60-Whi
choft
hef
oll
owi
ngi
sacor
ecomponentofHi
ber
nat
e?

A-Tr
ansact
ion

B-Sessi
onFact
ory
C-Sessi
on

D-Al
loft
heabov
e

Q61-nameat tr
ibut
eof@Col
umnannot
ati
onper
mit
sthenameoft
hecol
umnt
obe
expl
i
cit
lyspeci
fi
ed.

A-t
rue

B-f
alse

Q62-Whi
choft
hef
oll
owi
ngi
str
ueabout<pr
oper
ty>el
ement
?

A-The<pr
oper
ty>el
ementi
susedt
omapaJav
acl
asspr
oper
tyt
oacol
umni
nthe
dat
abaset
abl
e.

B-Thenameat
tri
but
eoft
heel
ementr
efer
stot
hepr
oper
tyi
nthecl
ass.

C-Thecol
umnat
tri
but
eoft
heel
ementr
efer
stot
hecol
umni
nthedat
abaset
abl
e.

D-Al
loft
heabov
e.

Q63-Whi
choft
hef
oll
owi
ngi
str
ueabout@Ent
it
yannot
ati
on?

A-@Ent
it
yannot
ati
onmar
ksacl
assasanent
it
ybean.

B-Classmarkedwith@Entit
yannot
ati
onmusthav
eano-
argumentconst
ruct
ort
hat
i
svisi
blewi
thatleastpr
otect
edscope.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q64-Whi
choft
hef
oll
owi
ngi
str
ueaboutHi
ber
nat
e?

A-Hibernatet
akescar
eofmappingJav
acl
assest
odat
abaset
abl
esusi
ngXMLf
il
es
andwithoutwri
ti
nganyli
neofcode.

B-Hi
bernateprovi
dessimpl
eAPI
sforst
ori
ngandr
etr
iev
ingJav
aobj
ect
sdi
rect
lyt
o
andf
rom thedatabase.

C-Hi
ber
nateabstract
sawayt
heunf
ami
l
iarSQLt
ypesandpr
ovi
deust
owor
kar
ound
f
amil
i
arJav
aObj ects.

D-Al
loft
heabov
e.

Q65-Session.
beginTr
ansacti
onmet
hodbegi
nsauni
tofwor
kandr
etur
nst
he
associ
atedTr
ansacti
onobject
.
A-t
rue

B-f
alse

Q66-Whichel
ementofhbm.
xml
isusedt
omapaJav
acl
asspr
oper
tyt
oacol
umni
n
t
hedat
abasetabl
e?

A-i
d

B-gener
ator

C-pr
oper
ty

D-cl
ass

Q67-WhenaRead-
wri
teconcur
rencyst
rat
egyi
stobeused?

A-Usei
tforr
efer
encedat
aonl
y.

B-Uset hi
sstrat
egyforr
ead-
most
lydat
awher
eiti
scr
it
ical
topr
eventst
aledat
ain
concur
renttr
ansact
ions.

C-Usethisstr
ategyi
fdat
ahar
dlyev
erchangesandasmal
ll
ikel
i
hoodofst
aledat
ais
notofcr
it
ical
concern.

D-Noneoft
heabov
e.

Q68-Whi
choft
hef
oll
owi
ngi
str
ueabout<cl
ass>el
ement
?

A-The<class>el
ementsar
eusedt
odef
inespeci
fi
cmappi
ngsf
rom aJav
acl
asses
t
othedatabasetabl
es.

B-TheJav
acl
assnamei
sspeci
fi
edusi
ngt
henameat
tri
but
eoft
hecl
assel
ement
.

C-Thedat
abaset
abl
enamei
sspeci
fi
edusi
ngt
het
abl
eat
tri
but
eoft
hecl
ass
el
ement
.

D-Al
loft
heabov
e.

Q69-Whi
choft
hef
oll
owi
ngt
ool
s/f
ramewor
kspr
ovi
desi
ntegr
ati
onwi
thHi
ber
nat
e?

A-XDocl
etSpr
ing

B-J2EE

C-Mav
en

D-Al
loft
heabov
e.
Q70-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Col
l
ect
ionpr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>

C-<bag>

D-<map>

Q71-Whi
choft
hef
oll
owi
ngi
str
ueaboutI
NSERTCLAUSEi
nHQL?

A-HQLsupportsI
NSERTINTOcl
auseonl
ywher
erecor
dscanbei
nser
tedf
rom one
obj
ectt
oanotherobj
ect
.

B-HQLsuppor
tsI
NSERTI
NTOcl
ausewi
thoutanyr
est
ri
cti
on.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q72-Whi
choft
hef
oll
owi
ngi
sther
ootnodeofhbm.
xml
fil
e?

A-hi
ber
nat
e-mappi
ng

B-hi
ber
nat
e-conf
ig

C-cl
ass-
mappi
ng

D-cl
ass-
conf
ig
Q1-WhatORM st
andsf
or?

A-Obj
ectRel
ati
onMap

B-Obj
ectRel
ati
onal
Mappi
ng

C-Obj
ectRecor
dMappi
ng

D-Noneoft
heabov
e.

Q2-Whi
choft
hef
oll
owi
ngi
str
ueaboutconf
igur
ati
oncomponentofHi
ber
nat
e?

A-TheConfi
gur
ati
onobj
ecti
sthef
ir
stHi
ber
nat
eobj
ecty
oucr
eat
einanyHi
ber
nat
e
appl
i
cat
ion.

B-TheConf
igur
ati
onobj
ecti
susual
l
ycr
eat
edonl
yoncedur
ingappl
i
cat
ioni
nit
ial
i
zat
ion.

C-TheConfi
gur
ati
onobj
ectr
epr
esent
saconf
igur
ati
onorpr
oper
ti
esf
il
erequi
redbyt
he
Hi
bernat
e.

D-Al
loft
heabov
e.

Q3-Sessi
on.
creat
eQuer
ycr
eat
esanewi
nst
anceofQuer
yfort
hegi
venHQLquer
y
st
ri
ng.

A-t
rue

B-f
alse

Q4-Whichel
ementofhbm.xmldefi
nesmapst
heuni
queI
Dat
tri
but
eincl
asst
othe
pr
imar
ykeyofthedat
abasetabl
e?

A-i
d

B-gener
ator

C-pr
imar
yKey

D-Noneoft
heabov
e.

Q5-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Sor
tedMappr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>
C-<bag>

D-<map>

Q6-Whati
slazyl
oadi
ng?

A-Laz
yloadi
ngi
sat
echni
quei
nwhi
chobj
ect
sar
eloadedondemandbasi
s.

B-Lazyl
oadi
ngi
sat
echni
quei
nwhi
chobj
ect
sar
eper
sist
edondemandbasi
s.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q7-Whati
sfi
rstl
evel
cachei
nhi
ber
nat
e?

A-Thef
ir
st-
lev
elcachei
stheSessi
onbasedcache.

B-Thef
ir
st-
lev
elcachei
stheSessi
onFact
orybasedcache.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q8-WhenaTr
ansact
ional
concur
rencyst
rat
egyi
stobeused?

A-Usei
tforr
efer
encedat
aonl
y.

B-Uset hi
sstrat
egyforr
ead-
most
lydat
awher
eiti
scr
it
ical
topr
eventst
aledat
ain
concur
renttr
ansact
ions.

C-Usethisstr
ategyi
fdat
ahar
dlyev
erchangesandasmal
ll
ikel
i
hoodofst
aledat
ais
notofcr
it
ical
concern.

D-Noneoft
heabov
e.

Q9-Whi
choft
hef
oll
owi
ngi
sacor
ecomponentofHi
ber
nat
e?

A-Tr
ansact
ion

B-Sessi
onFact
ory

C-Sessi
on

D-Al
loft
heabov
e
Q10-Whi
choft
hef
oll
owi
ngi
str
ueabout@Gener
atedVal
ueannot
ati
on?

A-@Gener
atedVal
ueannot
ati
ont
akest
wopar
amet
ersst
rat
egyandgener
ator
.

B-@Gener
atedVal
ueannot
ati
onpr
ovi
dest
hepr
imar
ykeygener
ati
onst
rat
egyt
obeused.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q11-Whi
choft
hef
oll
owi
ngi
snotanORM f
ramewor
k?

A-Cast
or

B-Spr
ingDAO

C-Hi
ber
nat
e

D-NoSQL

Q12-Whi
choft
hef
oll
owi
ngi
str
ueaboutSessi
onFact
oryobj
ecti
nhi
ber
nat
e?

A-TheSessi
onFact
oryi
sheav
ywei
ghtobj
ect
.

B-Sessi
onFact
oryobj
ecti
scr
eat
eddur
ingappl
i
cat
ionst
artupandkeptf
orl
ateruse.

C-YouwouldneedoneSessi
onFact
oryobj
ectperdat
abaseusi
ngasepar
ate
conf
igur
ati
onf
il
e.

D-Al
loft
heabov
e.

Q13-Whi
choft
hef
oll
owi
ngi
str
ueaboutt
ransi
entst
ateofaper
sist
entent
it
y?

A-Anewi
nst
anceofaper
sist
entcl
asswhi
chi
snotassoci
atedwi
thaSessi
on.

B-Anewi
nst
anceofaper
sist
entcl
asswhi
chhasnor
epr
esent
ati
oni
nthedat
abase.

C-Anewi
nst
anceofaper
sist
entcl
asswhi
chhasnoi
dent
if
ierv
alue.

D-Al
loft
heabov
e.

Q14-Whi chmet
hodisusedt
ore-
readt
hest
ateoft
hegi
veni
nst
ancef
rom t
he
under
lyi
ngdat
abase?

A-Sessi
on.
ref
resh(
)
B-Sessi
on.
get
()

C-Sessi
on.
rel
oad(
)

D-Sessi
on.
ret
ri
eve(
)

Q15-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Li
stpr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>

C-<bag>

D-<map>

Q16-Chil
dobj ectsarenotloadedwhenpar
enti
sloaded/
popul
atedf
rom dat
abase.
Whatt
histechniqueiscall
ed?

A-EagerLoadi
ng

B-LazyLoadi
ng

C-RequestbasedLoadi
ng

D-Noneoft
heabov
e.

Q17-WhatHQLst
andsf
or?

A-Hi
ber
nat
eQuer
yLanguage

B-Hi
ghQuer
yLanguage

C-Hy
bri
dQuer
yLanguage

D-Noneoft
heabov
e.

Q18-Whi
choft
hef
oll
owi
ngdat
abasei
snotsuppor
tedbyHi
ber
nat
e?

A-Or
acl
e

B-Mi
crosof
tSQLSer
verDat
abase

C-Foundat
ionDB

D-I
nfor
mixDy
nami
cSer
ver
Q19-ASessi
oni
susedt
ogetaphy
sical
connect
ionwi
thadat
abase.

A-t
rue

B-f
alse

Q20-Whi
choft
hef
oll
owi
ngi
str
ueaboutHQL?

A-Hi
ber
nat
esuppor
tsnamedpar
amet
ersi
nit
sHQLquer
ies.

B-HQLsuppor
tsar
angeofaggr
egat
emet
hods,
simi
l
art
oSQL.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q21-Whi
choft
hef
oll
owi
ngi
str
ueaboutHi
ber
nat
e?

A-Hi
ber
nat
eisanObj
ect
-Rel
ati
onal
Mappi
ng(
ORM)sol
uti
onf
orJAVA.

B-Hi
ber
nat
eisanObj
ect
-Rel
ati
onal
Mappi
ng(
ORM)sol
uti
onf
or.
NET

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q22-Whi chofthef
oll
owi
ngi
str
ueabouthi
ber
nat
e.di
alectpr
oper
tyi
nhi
ber
nat
e
conf
igur
ation?

A-Thispr
oper
tymakesHi
ber
nat
egener
atet
heappr
opr
iat
eSQLf
ort
hechosen
dat
abase.

B-Thi
sproper
tymakesHi
ber
nat
egener
atet
heappr
opr
iat
ejav
acodef
ort
hechosen
dat
abase.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q23-Whichmet
hodi
susedt
osav
ethest
ateoft
hegi
veni
nst
ancef
rom t
heunder
lyi
ng
dat
abase?

A-Sessi
on.
stor
e()
B-Sessi
on.
keep(
)

C-Sessi
on.
sav
e()

D-Sessi
on.
load(
)

Q24-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Mappr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>

C-<bag>

D-<map>

Q25-Whati
sQuer
ylev
elcachei
nhi
ber
nat
e?

A-Thequer y
-l
evelcachei
scachef
orquer
yresul
tset
sthati
ntegr
atescl
osel
ywi
tht
he
second-
lev
elcache.

B-Thequer
y-l
evel
cachei
stheSessi
onbasedcache.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q26-Whi
choft
hef
oll
owi
ngi
saconcur
rencyst
rat
egi
esi
nhi
ber
nat
e?

A-Tr
ansact
ional

B-Read-
wri
te

C-Nonst
ri
ct-
read-
wri
te.

D-Al
loft
heabov
e.

Q27-Whi
choft
hef
oll
owi
ngi
str
ueabout@I
dannot
ati
on?

A-Hi
ber
nat
edet
ect
sthatt
he@I
dannot
ati
oni
sonaf
iel
d.

B-Hiber
nateassumest
hati
tshoul
daccesspr
oper
ti
esonanobj
ectdi
rect
lyt
hrough
f
iel
dsatrunt
ime.

C-Bot
hoft
heabov
e.
D-Noneoft
heabov
e.

Q28-Whi
choft
hef
oll
owi
ngi
str
ueaboutHQL?

A-HQLqueriesar
etr
ansl
atedbyHi
ber
nat
eint
oconv
ent
ional
SQLquer
ieswhi
chi
ntur
ns
per
for
m act
ionondat
abase.

B-TheAScl
ausecanbeusedt
oassi
gnal
i
asest
othecl
assesi
nHQLquer
ies.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q29-Whi
choft
hef
oll
owi
ngi
str
ueaboutORM?

A-ORM st
andsf
orObj
ect
-Rel
ati
onal
Mappi
ng.

B-ORM i
sapr
ogr
ammi
ngt
echni
quef
orconv
ert
ingdat
abet
weenr
elat
ional
dat
abases.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q30-Whi
choft
hef
oll
owi
ngi
str
ueaboutQuer
yobj
ecti
nhi
ber
nat
e?

A-Queryobj
ect
sHiber
nateQuer
yLanguage(
HQL)st
ri
ngt
oret
ri
evedat
afr
om t
he
dat
abaseandcr
eat
eobjects.

B-Quer
yobj
ect
sSQLst
ri
ngt
oret
ri
evedat
afr
om t
hedat
abaseandcr
eat
eobj
ect
s.

C-AQueryi
nst
anceisusedtobindquerypar
ameter
s,l
imi
tthenumberofr
esul
ts
r
etur
nedbyt
hequery
, andf
inal
l
yt oexecut
ethequer
y.

D-Al
loft
heabov
e.

Q31-Sessi
on.
creat
eSQLQuer
ycr
eat
esanewi
nst
anceofQuer
yfort
hegi
venSQLquer
y
st
ri
ng.

A-t
rue

B-f
alse

Q32-Whi
chmet
hodi
susedt
ogetaper
sist
enti
nst
ancef
rom t
hedat
ast
ore?

A-Sessi
on.
read(
)
B-Sessi
on.
get
()

C-Sessi
on.
ret
ri
eve(
)

D-Sessi
on.
fet
ch(
)

Q33-Whi
choft
hef
oll
owi
ngi
str
ueabout<gener
ator
>el
ement
?

A-The<generat
or>el
ementwi
thi
nthei
del
ementi
susedt
oaut
omat
ical
l
ygener
atet
he
pr
imar
ykeyv al
ues

B-Sett heclassattr
ibut
eofthegenerat
orel
ementissettonat
ivet
olethibernat
epi
ck
upeitheridenti
ty,
sequenceorhi
loalgor
it
hm t
ocreatepri
marykeydependingupont
he
capabil
iti
esoftheunderlyi
ngdat
abase.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q34-Whi
choft
hef
oll
owi
ngel
ementi
susedt
orepr
esentone-
to-
manyr
elat
ionshi
pin
hi
ber
nat
e?

A-<one-
to-
many
>

B-<one-
many
>

C-<OneToMany
>

D-Noneoft
heabov
e.

Q35-I
squer
ylev
elcachi
ngmandat
oryi
nhi
ber
nat
e?

A-t
rue

B-f
alse

Q36-WhenaRead-
onl
yconcur
rencyst
rat
egyi
stobeused?

A-Usei
tforr
efer
encedat
aonl
y.

B-Uset hi
sstrat
egyforr
ead-
most
lydat
awher
eiti
scr
it
ical
topr
eventst
aledat
ain
concur
renttr
ansact
ions.

C-Usethisstr
ategyi
fdat
ahar
dlyev
erchangesandasmal
ll
ikel
i
hoodofst
aledat
ais
notofcr
it
ical
concern.
D-Noneoft
heabov
e.

Q37-Whi
choft
hef
oll
owi
ngi
str
ueabouthi
ber
nat
eannot
ati
ons?

A-Hiber
nateAnnot
ati
onsist
hepower
ful
wayt
opr
ovi
det
hemet
adat
afort
heObj
ectand
Rel
ati
onalTabl
emapping.

B-Allt
hemetadat
aiscl
ubbedi
ntothePOJOj
avaf
il
eal
ongwi t
hthecodethi
shel
psthe
usert
ounder
standthet
abl
estr
uctur
eandPOJOsi
mult
aneousl
yduri
ngthedevel
opment.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q38-Whi
choft
hef
oll
owi
ngi
snotacor
ecomponentofHi
ber
nat
e?

A-JDBC

B-Sessi
onFact
ory

C-Sessi
on

D-Conf
igur
ati
on

Q39-I
sSessi
onat
hread-
saf
eobj
ect
?

A-t
rue

B-f
alse

Q40-Whi
chmet
hodi
susedt
oremov
eaper
sist
enti
nst
ancef
rom t
hedat
ast
ore?

A-Sessi
on.
del
ete(
)

B-Sessi
on.
remov
e()

C-Sessi
on.
del
()

D-Sessi
on.
rm(
)

Q41-Whi chmethodisusedt
osav
eorupdat
ethest
ateoft
hegi
veni
nst
ancef
rom t
he
under
lyi
ngdatabase?

A-Sessi
on.
sav
eOr
Updat
e()
B-Sessi
on.
keep(
)

C-Sessi
on.
updat
e()

D-Sessi
on.
load(
)

Q42-I
sfi
rstl
evel
cachi
ngmandat
oryi
nhi
ber
nat
e?

A-t
rue

B-f
alse

Q43-Whi
choft
hef
oll
owi
ngdat
abasei
ssuppor
tedbyHi
ber
nat
e?

A-DB2/
NT

B-Post
greSQL

C-Sy
baseSQLSer
ver

D-Al
loft
heabov
e

Q44-Conf
igur
ati
onobj
ecti
susedt
ocr
eat
eSessi
onFact
oryobj
ecti
nhi
ber
nat
e.

A-t
rue

B-f
alse

Q45-nameat tr
ibut
eof@Col
umnannot
ati
onper
mit
sthenameoft
hecol
umnt
obe
expl
i
cit
lyspeci
fi
ed.

A-t
rue

B-f
alse

Q46-Whi
choft
hef
oll
owi
ngi
str
ueaboutTr
ansact
ionobj
ecti
nhi
ber
nat
e?

A-ATr
ansact
ionr
epr
esent
sauni
tofwor
kwi
tht
hedat
abase.

B-Tr
ansact
ionsi
nHi
ber
nat
ear
ehandl
edbyanunder
lyi
ngt
ransact
ionmanager
.

C-Thisisanopt
ional
obj
ectandHibernat
eappl
icat
ionsmaychoosenott
ouset
his
i
nter
face,i
nst
eadmanagi
ngtransact
ionsi
nthei
rownappli
cat
ioncode.
D-Al
loft
heabov
e

Q47-Session.
beginTr
ansacti
onmet
hodbegi
nsauni
tofwor
kandr
etur
nst
he
associ
atedTr
ansacti
onobject
.

A-t
rue

B-f
alse

Q48-Whi
chel
ementofhbm.
xml
aut
omat
ical
l
ygener
atet
hepr
imar
ykeyv
alues?

A-i
d

B-gener
ator

C-pr
imar
yKey

D-Noneoft
heabov
e.

Q49-Whati
sthedi
ff
erencebet
weenget
()andl
oad(
)met
hodsofsessi
onobj
ect
?

A-get
()r
eturnsnul
lifnodataispresentwhereasloadt
hrows
Obj
ect
NotFoundExcepti
onexcepti
oni nsuchcase.

B-get
()al
way
shi
tst
hedat
abasewher
easl
oad(
)met
hoddoesn'
thi
tthedat
abase.

C-get
()r
etur
nsact
ual
obj
ectwher
easl
oad(
)ret
urnspr
oxyobj
ect
.

D-Al
loft
heabov
e.

Q50-TheSessi
onFact
oryi
sheav
ywei
ghtobj
ect
.

A-f
alse

B-t
rue

Q51-Whi
choft
hef
oll
owi
ngi
str
ueaboutHQL?

A-Hi
ber
nat
eQuer
yLanguage(
HQL)i
sanobj
ect
-or
ient
edquer
ylanguage.

B-I
nst
eadofoper
ati
ngont
abl
esandcol
umns,
HQLwor
kswi
thper
sist
entobj
ect
sand
t
hei
rpr
oper
ti
es.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.
Q52-Whi
choft
hef
oll
owi
ngi
str
ueaboutSessi
onFact
oryobj
ecti
nhi
ber
nat
e?

A-TheSessi
onFact
oryi
sheav
ywei
ghtobj
ect
.

B-Sessi
onFact
oryobj
ecti
scr
eat
eddur
ingappl
i
cat
ionst
artupandkeptf
orl
ateruse.

C-YouwouldneedoneSessi
onFact
oryobj
ectperdat
abaseusi
ngasepar
ate
conf
igur
ati
onf
il
e.

D-Al
loft
heabov
e.

Q53-Whi
choft
hef
oll
owi
ngsi
tuat
ionr
epr
esent
smany
-to-
manyr
elat
ionshi
p?

A-Anempl
oyeecanhav
emul
ti
plecer
ti
fi
cat
esandsamecer
ti
fi
cat
ecanbeconf
err
edt
o
manyempl
oyees.

B-Anempl
oyeecanhav
emul
ti
plecer
ti
fi
cat
es.

C-Acer
ti
fi
cat
ecanbeconf
err
edt
omanyempl
oyees.

D-Al
loft
heabov
e.

Q54-Whati
ssecondl
evel
cachei
nhi
ber
nat
e?

A-Thesecond-l
evelcacheistheSessionFact
orybasedcacheandi
smai
nlyr
esponsi
ble
f
orcachi
ngobjectsacrosssessions.

B-Thesecond-
lev
elcachei
stheSessi
onbasedcache.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q55-Whi
choft
hef
oll
owi
ngi
str
ueabout@Col
umnannot
ati
on?

A-The@Columnannotat
ioni
susedt
ospeci
fyt
hedet
ail
soft
hecol
umnt
owhi
chaf
iel
d
orpr
oper
tywil
lbemapped.

B-The@Col
umnannot
ati
oni
sappl
i
edonacl
ass.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.
Q56-Whi
choft
hef
oll
owi
ngobj
ecti
susedt
ocr
eat
eSessi
onFact
oryobj
ecti
nhi
ber
nat
e?

A-Conf
igur
ati
on

B-Sessi
on

C-Sessi
onFact
ory

D-Tr
ansact
ion

Q57-Sessi
on.
creat
eQuer
ycr
eat
esanewi
nst
anceofQuer
yfort
hegi
venHQLquer
y
st
ri
ng.

A-t
rue

B-f
alse

Q58-Whi
choft
hef
oll
owi
ngi
str
ueabout<i
d>el
ement
?

A-The<id>el
ementmapst
heuni
queI
Dat
tri
but
eincl
asst
othepr
imar
ykeyoft
he
dat
abasetabl
e.

B-Thenameat
tri
but
eoft
hei
del
ementr
efer
stot
hepr
oper
tyi
nthecl
ass.

C-Thecol
umnat
tri
but
eoft
hei
del
ementr
efer
stot
hecol
umni
nthedat
abaset
abl
e.

D-Al
loft
heabov
e.

Q59-I
ssecondl
evel
cachi
ngmandat
oryi
nhi
ber
nat
e?

A-t
rue

B-f
alse

Q60-Whi
choft
hef
oll
owi
ngi
sacor
ecomponentofHi
ber
nat
e?

A-Tr
ansact
ion

B-Sessi
onFact
ory

C-Sessi
on

D-Al
loft
heabov
e

Q61-nameat
tri
but
eof@Col
umnannot
ati
onper
mit
sthenameoft
hecol
umnt
obe
expl
i
cit
lyspeci
fi
ed.

A-t
rue

B-f
alse

Q62-Whi
choft
hef
oll
owi
ngi
str
ueabout<pr
oper
ty>el
ement
?

A-The<pr
oper
ty>el
ementi
susedt
omapaJav
acl
asspr
oper
tyt
oacol
umni
nthe
dat
abaset
abl
e.

B-Thenameat
tri
but
eoft
heel
ementr
efer
stot
hepr
oper
tyi
nthecl
ass.

C-Thecol
umnat
tri
but
eoft
heel
ementr
efer
stot
hecol
umni
nthedat
abaset
abl
e.

D-Al
loft
heabov
e.

Q63-Whi
choft
hef
oll
owi
ngi
str
ueabout@Ent
it
yannot
ati
on?

A-@Ent
it
yannot
ati
onmar
ksacl
assasanent
it
ybean.

B-Classmar
kedwi th@Enti
tyannot
ati
onmusthav
eano-
argumentconst
ruct
ort
hati
s
vi
sibl
ewit
hatleastprot
ect
edscope.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q64-Whi
choft
hef
oll
owi
ngi
str
ueaboutHi
ber
nat
e?

A-Hibernatet
akescar
eofmappingJav
acl
assest
odat
abaset
abl
esusi
ngXMLf
il
es
andwithoutwri
ti
nganyli
neofcode.

B-Hibernat
epr ovi
dessi
mpl
eAPI
sforst
ori
ngandr
etr
iev
ingJav
aobj
ect
sdi
rect
lyt
oand
f
rom thedatabase.

C-Hi
ber
nateabstract
sawayt
heunf
ami
l
iarSQLt
ypesandpr
ovi
deust
owor
kar
ound
f
amil
i
arJav
aObj ects.

D-Al
loft
heabov
e.

Q65-Session.
beginTr
ansacti
onmet
hodbegi
nsauni
tofwor
kandr
etur
nst
he
associ
atedTr
ansacti
onobject
.

A-t
rue
B-f
alse

Q66-Whichel
ementofhbm.
xml
isusedt
omapaJav
acl
asspr
oper
tyt
oacol
umni
n
t
hedat
abasetabl
e?

A-i
d

B-gener
ator

C-pr
oper
ty

D-cl
ass

Q67-WhenaRead-
wri
teconcur
rencyst
rat
egyi
stobeused?

A-Usei
tforr
efer
encedat
aonl
y.

B-Uset hi
sstrat
egyforr
ead-
most
lydat
awher
eiti
scr
it
ical
topr
eventst
aledat
ain
concur
renttr
ansact
ions.

C-Usethisstr
ategyi
fdat
ahar
dlyev
erchangesandasmal
ll
ikel
i
hoodofst
aledat
ais
notofcr
it
ical
concern.

D-Noneoft
heabov
e.

Q68-Whi
choft
hef
oll
owi
ngi
str
ueabout<cl
ass>el
ement
?

A-The<class>el
ement
sar
eusedt
odef
inespeci
fi
cmappi
ngsf
rom aJav
acl
assest
o
t
hedatabasetabl
es.

B-TheJav
acl
assnamei
sspeci
fi
edusi
ngt
henameat
tri
but
eoft
hecl
assel
ement
.

C-Thedat
abaset
abl
enamei
sspeci
fi
edusi
ngt
het
abl
eat
tri
but
eoft
hecl
assel
ement
.

D-Al
loft
heabov
e.

Q69-Whi
choft
hef
oll
owi
ngt
ool
s/f
ramewor
kspr
ovi
desi
ntegr
ati
onwi
thHi
ber
nat
e?

A-XDocl
etSpr
ing

B-J2EE

C-Mav
en

D-Al
loft
heabov
e.
Q70-Whi
choft
hef
oll
owi
ngel
ementmapsj
ava.
uti
l
.Col
l
ect
ionpr
oper
tyi
nhi
ber
nat
e?

A-<set
>

B-<l
i
st>

C-<bag>

D-<map>

Q71-Whi
choft
hef
oll
owi
ngi
str
ueaboutI
NSERTCLAUSEi
nHQL?

A-HQLsupportsI
NSERTINTOcl
auseonl
ywher
erecor
dscanbei
nser
tedf
rom one
obj
ectt
oanotherobj
ect
.

B-HQLsuppor
tsI
NSERTI
NTOcl
ausewi
thoutanyr
est
ri
cti
on.

C-Bot
hoft
heabov
e.

D-Noneoft
heabov
e.

Q72-Whi
choft
hef
oll
owi
ngi
sther
ootnodeofhbm.
xml
fil
e?

A-hi
ber
nat
e-mappi
ng

B-hi
ber
nat
e-conf
ig

C-cl
ass-
mappi
ng

D-cl
ass-
conf
ig
1) In Spring AOP, the process of linking aspect with other application types or objects to create an advice
object is called ---------Weaving

2) <list> tag is used to wire a list of values, allowing duplicates.

3) BeanFactory, ApplicationContext classes acts as IoC containers in Spring.

4) Can you inject null and empty string values in Spring? -----yes

5) AOP stands for Aspect Oriented Programming.

6) SpEL is NOT part of core container-------false

7)Following class can be extended to create custom event in spring.


A) SpringEvent
B)Event
C)ApplicationEvent
D)None of above

8)Which is the way to provide configuration metadata to spring?


A) XML Based configuration file.
B)Annotation based configuration.
C)Java based configuration.
d)all of listed

9)Which of the following are modules of Web layer?


A )Servlet, Web, Portlet, WebSocket
B)WebSocket, Servlet, Web-MVC, Web
C)HTML, JSP, WEB, Portlet
D)HTML, Servlet, WEB, Portlet
10) How many instances can be created for a global session ----one
11) What display the data with help of model? ----- View

12) Which of the following is correct assertion about spring?


I.Spring enables developers to develop enterprise-class applications using POJOs.
II.Spring is organized in a modular fashion.
III.Testing an application written with Spring is simple
IV. All of the list

13) How after advice works?


A) Run advice after a method execution regardless of its outcome
B)Run advice after a class loads.
C)Run advice after http response is returned.
D)Run advice after http request is processed.

14) What is true about <list> collection configuration elements?


A.This helps in wiring a list of values, allowing duplicates.----------<list>
B.This helps in wiring a list of values but without any duplicates.-----<set>
C.This can be used to inject a collection of name-value pairs where name and value can be of
any type.--------<map>
D.This can be used to inject a collection of name-value pairs where the name and value are
both Strings.----------<props>

15) Element which can be used to inject a collection of name-value pairs where the name and the value can
be of any type.
a)<list>
b)<set>
c)<map>
d)<props>
16)Element which can be used to inject a collection of name-value pairs where the name and the value are
both Strings type.
a)<list>
b)<set>
c)<map>
d)<props>

17)What is ContextStartedEvent event?


A) This event is published when the Servlet Context is either initialized or refreshed.
B)This event is published when the HTTP Request is received.
C)This event is published when the ApplicationContext is started using the start() method on the
ConfigurableApplicationContext interface.
D)This event is published when the HTTP Response is returned.

18) What is ContextClosedEvent event?


A) This event is published when the Servlet Context is either initialized or refreshed.
B)This event is published when the HTTP Request is received.
C)This event is published when the HTTP Response is returned.
D)This event is published when the ApplicationContext is closed using the close method on the
ConfigurableApplicationContext interface.

19) Which of the following is true about @Entity annotation?


A) @Entity annotation marks a class as an entity bean.
B)Class marked with @Entity annotation must have a no-argument constructor that is visible with at least
protected scope.
C)Both of the above.
D)None of the above.
20) Which of the following not available in HQL?
a)Select
b)Where
c)Sub
d)Having

21)Which of the following is an available aggregate function in HQL?


a.Aggregate(property name)
b.Count(property name or *)
c.max(property name)
d.avg(property name)

22)Which of the following database is not supported by Hibernate?


A) DB2/NT
B)MySQL
C)FoundationDB
D)PostgreSQL

23)Which of the following is true about Hibernate?


A) Hibernate is an Object-Relational Mapping(ORM) solution for JAVA
B)Hibernate is an Object-Relational Mapping(ORM) solution for .NET
C)Both of the above.
D)None of the above.

24)ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data
between relational databases.-----------True
25)What is the difference between save() and persist() methods of session object?
A) There is no difference.
B)save saves the object and returns status whereas persist stores status in different variable.
C)save saves the object and returns the id of the instance whereas persist do not return anything
after saving the instance.
D)None of the above.

26) What is required to write a basic spring program?


jdk,ide,maven,all the above

27)JDBC, ORM, OXM, JMS, Transactions are the modules of Data Access/ Integration layer.------True

28)Spring framework is a light weight framework.------TRUE

29) Singleton is the default scope of any spring bean. -----TRUE

30)Analyze the below code snippet:


<bean class="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao"/>
</bean>
<bean class="com.spring.repository.JpaDao"/>

Which of the following statements is valid?


I. The "id" attribute must be declared for the bean "MyServiceImpl" because it is mandatory attribute.
II. In the second bean of type "com.spring.repository.JpaDao" the “id" attribute must be specified with
name "jpaDao".
Select One
a. Both I and II are correct
b. II only
c. I only
d. Both I and II are incorrect
31)Which of the following parses in XML based on expression and its used extensively in conjugation with
xstl?
a)JDOM parser
b)SAX parser
c) STAX parser
d) Xpath parser

32) What is true about BeanFactory, ApplicationContext?


BeanFactory is basic and ApplicationContext is advanced

33)Which are the correct implementation classes of ApplicationContext?


A.FileSystemXmlApplicationContext,ClassPathXmlApplicationContext,
WebXmlApplicationContext
B.FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext
C.AdvancedApplicationContext, FileApplicationContext
D.FileSystemApplicationContext, ClassPathApplicationContext

34) org.springframework.web.servlet.DispatcherServlet is the configuration in xml file for


dispatcherServlet.

35) The central artifact in spring javaConfig is the @Configuration annotated class?-----True

36) Maven is a project management and comprehension tool-----True

37) What is session scope?


A) This scopes a bean definition to an HTTP session.
B)This scopes the bean definition to Spring IoC container.
C)This scopes the bean definition to HTTP request.
D)This scopes the bean definition to HTTP Application/ Global session
38) What of the following is not correct in live environment?
a. Constuctor and properties autowiring in the same bean are not compatible
b. A bean should have a default or a no-args constructor
c. The <constructor-arg> tag could take type, name and index to reduce ambiguity
d. All of the above

39) which is not core component of hibernate?


a.transaction
b.criteria
c.provider
d.query

40) ServletWrappingController-Wraps an existing servlet which is managed completely by the spring


environment.---------True

42)Validations for normal employee class


I.Name cant be empty
I.Id cant be empty
III.Id cant be less than 1
iv.all the above

44)Different types of run advice "before" and "after" the advised method is invoked. Which of the
following is the correct option with respect to advice?
a.After returning
b.None
c.After throwing
d.around
45)HQL- easily stores, update and retrieve from the database--------- True

46) Which of the following is Hibernate?


a.Lightweight
b.Open Source
c.ORM
d.All of the listed

48) When we work with an object oriented system, there is mismatch between the object model and the
relational database State True or False
a) TRUE
b) FALSE

49) Spring mvc is a model-view-controller.-------True

50) Form fields are validated using user defined validations class by implementing validation interface
State True or False.-------True

51) Spring does not separate three modules like presentation layer, business layer and data access layer
State True or False.-------False

52) Pick odd one out in the following annotations ( invalid annotations)
I.@PathValid II.@responsevalid
III.@Controller IV.@requestMapping

53) Length returns number of rows in a column for only string type.-------True

54) Which level cache implements a cache for query result sets
a.Third level cache
b.Second level cache
c.First level cache
d. Fourth level cache

57) What is the function of clean maven lifecycle command ?


cleans artifacts in the earlier build

60) Which of the following is a one to one relationship


a) <many-to-many>
b) <many-to-one>
c) None of the list
d) <one-to-many>

61) Which of the following is a many to one relationship


a) many-to-one
b) <many-to-one>
c) None of the list
d) <Manyone>

62) The same XSD of BeanFactory can be used for View resolver interface?
State True or False
a) TRUE
b) FALSE

63) Testing an application written with Spring is complex because environment-dependent


code is moved into this framework.---------false

64)What is ContextStoppedEvent event?

A) This event is published when the Servlet Context is either initialized or refreshed.
B)This event is published when the ApplicationContext is stopped using the stop() method on the
ConfigurableApplicationContext interface.
C)This event is published when the HTTP Request is received.
D)This event is published when the HTTP Response is returned.

65)XsltViewResolver-supports XsltView by resolving the view name of which of the following options
a) all of the listed options
b)VelocityView and its subclasses
c)URL of xslt
d)view name of the URL of the report file.

66) Spring MVC provides predefined templates for JDBC, Hibernate and JPA.---------True

67) ApplicationContext implements which of the following interface that is used to obtain localized
messages, with the actual implementation being pluggable
I. MessageSource
II. RequestMapping
a. only I
b.only II
c. Neither I or II
d. Both I and II

68) Which of the following are the best practices for writing spring XML Configurations?
a.Using consistent naming conventions
b. Rarely use classpath
c.Mentioning version numbers in schema references
d.reuse bean definitions as much as possible

69) To validate the form fields you need to have a separate UserValidator class that implements the
validator interface, Override the validate() method perform all the validations.---------True
70) Which of the listed options are TRUE for Bean configuration inheritance?
I. In spring, Inheritance is supported in bean configuration to share common values, properties or
configurations
II. A child bean or inherited bean can inherit its parent bean configurations, properties and some attributes
III. The parent bean allow to override the inherited values

a.I, II, and III


b.I and II
c.II and III
d.I and III

71) which of the following options about Auto wiring in spring are correct?
I. The Auto wiring in spring framework can be performed by configuring in xml and spring Auto-Wiring
with Annotation @Autowired
II. Auto-wiring beans with xml configuration: In Spring framework, you can wire beans automatically with
auto wiring feature
III. To enable auto-wiring just define the "autowire" attribute in <bean> tag.

a.I, II, and III


b.I and III
c.I and II
d.II and III

72) XML Mapping file offers which of the following?


a.Readable Metadata
b.Surrogate key generation strategy
c.Collecion metadata
d.all the listed options
e.Column/Table Mapping

73) Which of the following explains about addClass function in the listed options(doubt)
I. This function translates a Java class name into file name
II. This translated file name is then loaded as an input stream from the java class loader
III. This addClass function is important if you want efficient usage of classes in your code

a. I, II, and III


b. I and III
c. I and II
d. II and III

74) The application is designed around an object model. The SQL code is generated at build time and the
associations between objects are supported by the persistent mechanism, and queries are specified using an
object oriented expression language. This best suited for medium-sized applications with some complex
transactions. Used when the mappping exceeds 25 different databse products at a time.

Which of the following is this called as?


a. Application Object Mapping
b. Expression object mapping
c. Medium Object Mapping
d. Object Mapping

75) Which of the following is not the best practice?


a.Provide exit controller in the web
b.Create a controller class
c.start server 7 deploy the project
d.Define the bean in the xml file

76) What are the modules of spring web flow?


a.Spring-faces
b.Spring-bundling
c.Spring-container
d.Spring-webflow

77) Bean post processor is a concrete class----------false

78) The Spring MVC pattern does not separate the different aspects of the application into input logic,
business logic, and UI logic.-------------------false

79) Constructors in a class can be?


a. may be defined as private
b. Contains same name as class
c. used to create objects
d. all the above

80) Given the Spring configuration file, which are the correct statements?
<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>
a) The p namespace has to be declared
b) Bean id is bankServiceImpl
c) The BankServiceImpl references a NationalBank bean
d) NationalBank is a scalar value

81) Which is correct?


a. Hibernate is an object oriented query language
b. It is database independent
c. it supports pagination
d. HQL statements will be converted to SQL or other language the database supports
e. all the above

82) Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?
execution(public * *(..))
a) The execution of all public method
b) The execution of all public method returning a value
c) The execution of all public method having at least one parameter
d) The execution of all public method in class belonging to the default java package

83) What is the transaction behavior of the PROPAGATION_REQUIRES_NEW model? Select a unique
answer.
a) If a transaction exists, the current method should run within this transaction. Otherwise, it
should start a new transaction and run within its own transaction.
b) If a transaction is in progress, the current method should run within the nested transaction
of the existing transaction. Otherwise, a new transaction has to be started and run within its
own transaction.
c) The current method must start a new transaction and run within its own transaction. If there is an
existing transaction in progress, it is suspended.
d) None of the above

84) Types of autoproxing?


a. BeanNameAutoProxyCreator
b. DefaultAdvisorAutoProxyCreator
c. Metadata autoproxying
d. WebApplication context

85) Which scope is a single bean definition to have any number of object instances ? -----prototype

86) Which annotation is used in setter? which type of annotation applies to bean property setter methods
select one
a)@Requires
b)@Resource
c)@Required
d)@Requiring

87) Model is used to encapsulate the response data----------------True


88) What is a view resolver?
a) class
b) interface
c) object
d) argument

89) Cache enables the database to hit as much as possible for better performance in critical applications.----
------True

90) View Resolver provides a mapping between view names and actual views.-----------True

91) Which one interpret user input and transform it into a model that is represented to the user by the view.
a) controller
b) dispatcher servlet
c) model
d) browser

92) Assuming @Transactional annotation support is enabled and the transferMoney method is called
through a Spring AOP proxy, what is the behavior of the following code sample?
@Transactional(propagation=Propagation.REQUIRED)
public void transferMoney(Account src, Account target, double amount) {
add(src, -amount);
add(src, amount);
}
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void add(Account account, Double amount) {
// IMPLEMENTATION
}
a) The add() method executes code in a new transaction
b) The add() method uses the transaction of the transferMoney() method
c) When calling the add() method, an exception is thrown
d) Other behavior

93) Application contexts can publish events to beans that are registered as listeners.--------true

94) Which is not used as java annotation


a) @component
b) @bean
c) @configuration
d) none

95) Hibernate supports query cache-----------true


96) What are the mapping associations used in hibernate?
a. One-to-One Association
b. Many-to-One Association
c. One-to-Many Association
d. Many-to-Many Association

97) What are the different fetching strategies in hibernate?


a) Join Fetching
b) Batch Fetching
c) Select Fetching
d) Sub-select Fetching

98) Hibernate helps in mapping of java objects with database tables ---------------true

99) Which of the following are mandatory rules to create validation for a normal employee table?
a.The "empNum" cant be empty
b."Name" cant be empty
c.The "empNum" cant be less than 1
d.All of the option

100) Which of the following allows as to add a new method or attributes to existing classes?
a.Introduction
b.Proxy
c.Weaving
d.Auto call

111. Length attribute of @column annotation permits the size of the column used to map a value
particularly for a string value.--------true

112. Which of the following is true regarding prototype


a. scope is a single bean definition to have any number of object instances
b. it is the default scope in standard web applications
c. the instances will be created for each bean dependency
113.which mapping is given in hibernate in common?
a) object
b) relational
c) class
d) column
114.In which level, sql query is integrated in HQL?
a) class level
b) low level
c) high level
d) object level
115.In which way, the properties of one bean is used by number of beans?
a) inheritance
b) dependency injection
c) through child bean

116.In spring MVC each tag provides support to the set of attributes of its corresponding HTML tag
counterpart making the tags familiar & intuitive to use----------------True
117.We can use index and type attribute together-----------true

118.Which of the following is true about JDBC?


a.JDBC APIs enables java programs to execute SQL statements and interact with any SQL Complaint
database
b.JDBC stands for Java Database Connectivity
c.it provides set of java API for accessing the relational databases from java program
d.All the listed option

119.Which of the listed statement are correct for spring Bean


a) Spring container creates new instance of bean for each and every request for that bean
b) Prototype scoped bean is served by creating new instance of bean for each and every bean
dependency
c) After instantiating bean and submitting it to client spring container will maintain the record
d) Prototype scope is spring standard scope and can be used in standalone as well as web
application of spring.

120.Which is the query language that embodies a very powerful and flexible mechanism to query, store,
update and retrive
objects from a database?
a.PLSQL
b.RDBMS
c.SQL
d.HQL

121.What is spring MVC framework?


a.spring MVC framework is used for Transaction management for web application
b.spring MVC framework is Model-value-class architecture and used to bind model data
c.spring MVC framework is used for AOP for web application
d.spring web MVC framework provides model-view-controller architecture and ready components
that can be used to develop flexible and loosely coupled web applications

122.When you need to upload a large number of records into your database using Hibernate, you can use
batch processing.------true

123.Implementation of viewResolver accets a configuration file written in XML with the same DTD as
spring XML bean factories.---------true
124.For a fast Development, the dependency injection feature of spring Framework &support to various
Frameworks makes the easy development of javaEE application.-------true

125.In hibernate implement cache for a query ,if the result sets can integrate closely,which level
of the cache can be implemented?
a.first level cache
b.second level cache
c.third level cache
d.Fourth level cache

126.In Spring MVC which of the following is the front controller class that initializes the context
based on the spring beans configuration?
a.org.springframework.web.servlet.DispatcherServlet
b.org.springframework.web.context.DispatcherServlet
c.org.springframework.web.servlet
d.org.springframework.web.context.ApplicationContext

127.Which of the following statements are correct?


a.Bean Factory and ApplicationContext are basic container only
b.Bean Factory is basic container and ApplicationContext is advanced container
c.Bean Factory and ApplicationContext are advanced container
d.Bean Factory is advanced container and ApplicationContext is basic container

128.In spring bean configuration bean atribute called 'scope' defines what kind of object
has to be created and returned. What returns a new bean instance each time when required?
a.Prototype
b.Session
c.Singleton
d.Global session
129. Which of the following is true about Hibernate?
A) Hibernate takes care of mapping Java classes to database tables using XML files and without writing
any line of code.
B)Hibernate provides simple APIs for storing and retrieving Java objects directly to and from the database.
C)Hibernate abstracts away the unfamiliar SQL types and provide us to work around familiar Java Objects.
D)All of the above.

130.Spring MVC provides a JSP tag library(Spring form) for making it easier to bind form elements to
model data.-------True

131.Which of the following statement is INCORRECT by extending ViewResolver and


ChainingViewResolver?
a. programmers can have custom view resolvers
b. There are lot of view resolvers available in Spring framework
c. Spring MVC view resolvers help the Dispatcher Servlet in identifying the views which has to be
rendered in response for a request.
d.none

132. Spring MVC provides better way to separate which of the following?
a.Presentation
b.Tools
c.Data Access
d.Bussiness Logic(not sure)

133.It is difficult to inject the dependency by constructor. ------------true

134.The Model-View-Controller(MVC) is an architectural pattern that does not separate an application into
three main logical compponents: the model,the view and the controller.------false
135. How many layers are there in Hibernate architecture
a)3
b)4
c)5
d)2

136. Which tool helps to generate the mapping document Though many Hibernate users choose to write the
XML by hand
select one
a)oldgen
b)younggen
c)Middlegen
d) Mediumgen

137. Java based configuration option disables you to write most of your Spring configuration without XML
but with the help of few Java-based annotations ----------------False

138. What types of views supported by spring MVC for different presentation technologies
select one or more
a)JSP
b)HTML
c)velocity templates
d) all

139. Spring is a heavy weight framework---------------False

140. A very powerful and high performance qurerying language used to Query,retrive,store data in DB is
select one
a)PLSQL
b)HQL
c)SQL
d)RDBMS

141. Which best describes the propagation attribute REQUIRED?


a. Create a new transaction, suspend the current transaction if one exists.
b. Execute non-transactionally, suspend the current transaction if one exists.
c. Supports a current transaction, throw an exception if none exists
d. Support a current transaction, create a new one if none exists.

142. Which best describes the propagation attribute NON_SUPPORTED?


a. Create a new transaction, suspend the current transaction if one exists.
b. Execute non-transactionally, suspend the current transaction if one exists.
c. Supports a current transaction, throw an exception if none exists.
d. Support a current transaction, create a new one if none exists.

143.Which best describes the propagation attribute MANDATORY?


a. Create a new transaction, suspend the current transaction if one exists.
b. Execute non-transactionally, suspend the current transaction if one exists.
c. Supports a current transaction, throw an exception if none exists.
d. Support a current transaction, create a new one if none exists.

144. Which best describes the propagation attribute REQUIRES_NEW?


a. Create a new transaction, suspend the current transaction if one exists.
b. Execute non-transactionally, suspend the current transaction if one exists.
c. Supports a current transaction, throw an exception if none exists.
d. Support a current transaction, create a new one if none exists.

145. Can you instantiate a static inner class in Spring?


a. No, static classes are not supported
b. Yes, they are instantiated by default with the class.

146. An application server is required for spring's transaction mechanism to run.


a. TRUE
b. FALSE

147. What are the types of injection supported by Spring?


a. Constructor Injection only.
b. Constructor Injection and Setter Injection
c. Constructor Injection, Setter Injection and Interface Injection
d. Constructor Injection, Setter Injection before 2.0 and Interface Injection with 2.0 and above
version

148. @Inject annotation supports "required" attribute.


a) TRUE
b) FALSE

149. Which event is published when context is initialized?


a) ContextStartedEvent.
b) ContextRefreshedEvent
c) ContextInitializedEvent
d) ContextReadyEvent

150. Which event is published when context is refreshed?


a. ContextStartedEvent
b. ContextInitializedEvent
c. ContextReadyEvent
d. ContextRefreshedEvent

151. Spring Web MVC (and in Spring in general) is the "Open for extension, closed for modification"
principle.
The reason that this principle is being mentioned here is because a number of methods in the core classes in
Spring Web MVC are marked final.
a. true
b. false
152. Which of the among is not a special bean in WebApplicationContext?
a. Locale resolver
b. Theme resolver
c. multipart file
d. resolver
e. Handler exception resolver
f. Handler mappings
g. None of the above

153. How the Spring DispatcherServlet supports for returning the last-modification-date, as specified by
the Servlet API ?

a. By implementing the LastModified interface


b. By implementing the LastSessionModified interface
c. By implementing the LastDateModified interface
d. By implementing the LastModifiedDate interface

154. WebApplicationContext has more scopes like request, session, globalSession to the standard
Application context (which only provides Singleton and Prototype scopes)-----------true

155. All of Spring's various Controller inherit from AbstractControllor?--------true

156. You can write your own controller by using handleRequestInternal(HttpServletRequest,


HttpServletResponse) method from abstract controller and a ModelAndView object.-----true

157. Which of the following controller inspects the URL and retrieves the filename of the file request and
uses that as a viewname ?For example, the filename of http://www.springframework.org/welcome.html
request is welcome.
a. UrlFilenameViewController
b. MultiActionMultiActionController
c. CommandController
d. AbstractController

158. The available prefixes for ClassPathXmlApplicationContext look up are:-


classpath:
file:
http:
https:

159. Spring event mechanism is based on the standard:-


a. Observer Design Pattern
b. Factory Design Pattern
c. Mediator Design Pattern

160. What kind of servers can support Spring Transaction?


a. Only Application servers
b. Only Application servers which support J2EE specification
c. Spring's transactional services are supported on web servers also

161. In Spring Framework's declarative transaction implementation, is it sufficient to annotate to classes


with the @Transactional annotation? -------------NO

162. What is dependency injection?

a)A design pattern where dependent objects are defined in an xml for easy maintainability.
b)This is a design pattern whereby dependent objects are passed into an object from the
outside at the time application is initialized.
c)A unique feature of spring which allows object to be injected at the time of compilation.

163. Given following controller :-

@RequestMapping("/basket")
@Controller
public class Shopping {
@RequestMapping("/{id}")
public String doCheckOut(@PathVariable Date time) {
return "home";
}
}
Is declaration of Shopping#doCheckOut method correct?------------TRUE

164. If you were using Join Points, Pointcuts & Advice what would you be using?
a)Bean Contatiner
b)JPA
c)EJB
d)AOP

165. Spring 3.0 does not support for multipart form.-------False

166. Which of the following view technologies are supported by Spring?


a. JSTL/JSP
b. Ms Excel
c. Adobe PDF
d. All of the above.

167. Spring 3.0 provides the PropertyEditor for performing thread-safe type conversion. This allows any
Type to be converted to any other Type.-------------FALSE

168. For a given web.xml configuration:


<web-app version="2.5">
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Which path should has file that contains XML configuration metadata for ApplicationContext of given
DispatcherServlet?

/WEB-INF/application-context.xml
/dispatcher-servlet.xml
/WEB-INF/dispatcher-servlet.xml

169. Suppose I have an aspect:


@Before("execution(* method*()")
and the following class:
public class MyClass() {
public void method1() {
method2();
}
public void method2() {
}
}
If I call, myClass.method1(), from another class, which methods does the advice run against?
a. method1
b. method2
c. neither
d. both

170. The following methods :-


queryForInt(args)
queryForList(args)
getJdbcOperations()
getNamedParameterJdbsOperations()
are all present in which of the following class?
a. SimpleJdbcTemplate
b. JdbcTemplate
c. NamedParameterJdbcTemplate
d. None of the above

171. The dynamic languages currently supported by Spring are


a. Groovy
b. JRuby
c. BeanShell
d. All the above

172. JMS stands for-


a. Java Message Service
b. Java Mechanism Service
c. Java Message System
d. Java MultiThreaded System

173. Which of the following tag is used to enable Aspect using XML configuration?
a)<aop:aspectj-autoproxy/>
b)<aop:aspectj-component/>
c)<aop:aspectj/>
d)<aop:aspectj-autoproxy-component-scan/>

174. Programatic transaction management is done using:-


a)TransactionTemplate
b)PlatformTransactionManager
c)@TransactionManager
d)IntegratedTranaction

175. Which of the following are valid return types, or values, from a controller implementation?
a)null
b)A String view name
c)void
d)All of the above

176. Which of the following are JSR - 250 annotation/s?


a) @PreConstruct
b) @PreDestroy
c) @Resource
d) @PostConstruct
e) @Autowired
f) @Controller

177. In Spring's form tag library which of the following tags are valid?
a) input and inputs
b) checkbox and checkboxes
c) radiobutton and radiobuttons
d) redirect

Solution
checkbox and checkboxes are valid spring tags.
radiobutton and radiobuttons are valid spring tags.
input is valid spring tag but inputs is not a valid spring tag.

178. If you want to provide the MessageSource functionality to application, providing access to messages
in i18n-style in your application. Which one should be used?

a) ApplicationContext
b) Property File
c) Servlet Context

179. Can dependency injection be lazy initialized?


a) YES
b) NO
Solution
Using lazy-init="true" in spring configuration file on the bean, it can be instantiated only when needed.

180. What is second level cache in hibernate?


A) The second-level cache is the SessionFactory based cache and is mainly responsible for caching
objects across sessions.
B)The second-level cache is the Session based cache.
C)Both of the above.
D)None of the above.

181.What is the type of file used for spring configuration?


Ans:
 XML based configuration file.
 Annotation-based configuration
 Java-based configuration

182. What is the security annotation used in spring? (@autowire, @transicible ,……)
Ans :@PreAuthorize and @PostAuthorize

183. What are the types of editors used in spring framework?


Ans:
 PropertyEditor
 URLEditor
 ClassEditor
 CustomDateEditor
 FileEditor
 LocaleEditor
 StringArrayPropertyEditor
 StringTrimmerEditor

184. What is the use of ‘after return advice’?


Ans : Advice that is executed after the normal completion of a joinpoint is called the “after
returning advice”.

185. What are the things mapped in an XML? (Data type, value ,….)
186. Describe Global and Local transactions in Spring.
Ans: Global transactions help to work with multiple transactional resources like relational database and
message queue.
Global transactions are managed through JTA and JNDI. Local transactions are resource-specific like
JDBC connection.
Local Transactions can work with multiple transactional resources.

188. What is the role of TransactionDefinition interface?


a. Isolation
b. Propagation
c. Timeout
d. Read-only status

189. How can we roll back a declarative transaction?


We can use rollback-for and no-rollback-for attributes with transactional definition.

190. How many types of isolation are there?


a. ISOLATION_DEFAULT: default isolation.
b. ISOLATION_READ_COMMITTED: dirty reads are prevented, non-repeatable and phantom reads are
allowed.
c. ISOLATION_READ_UNCOMMITTED : dirty reads are allowed, no-repeatable and phantom reads are
allowed.
d. ISOLATION_REPEATABLE_READ: dirty reads and non-repeatable reads are prevented but phantom
reads are allowed.
e. ISOLATION_SERIALIZABLE : dirty , non- repeatable reads and phantom reads are prevented.

191. How many types of Propagation are there?


a. PROPAGATION_MANDATORY : supports current transaction and throws exception if no
transaction available.
b. PROPAGATION_NESTED : runs with nested transaction
c. PROPAGATION_NEVER : does not run with current transaction and throws exception if current
transaction exits.
d. PROPAGATION_NOT_SUPPORTED : runs non -transactionaly and does not support current
transaction.
e. PROPAGATION_REQUIRED : runs with current transaction and create one if does not exist.
f. PROPAGATION_REQUIRES_NEW : creates new transaction and suspends if exits any.
g. PROPAGATION_SUPPORTS: runs current transaction and runs non -transactionaly

192.Name attribute of @Column annotation permits the name of the column to be explicitly specified.
a) true
b) false

193. which of the following Allows you to add new methods or attributes to existing classes?
a.Advice
b.Join point
c.Aspect
d.Pointcut
e.Target object
f.Weaving
g.Introduction

194. Which of the statement is not correct?


A) Core and beans modules provide the fundamental parts of the framework, including Dependency
Injection feature.
B)The SpEL module provides a powerful Expression Language for querying and manipulating an object
graph at runtime.
C)Aspects module provides integration with AspectJ.
D)None of the above.

195. - SpEL is part of core container.


A) False
B)True
196 - Which are the modules of Web layer?
A) WebSocket, Servlet, Web, Portlet
B)WebSocket, Servlet, Web-MVC, Web
C)HTML, JSP, WEB, Portlet
D)HTML, Servlet, WEB, Portlet.

197. SpEX is NOT one of its module Core container.


A) True
B – False

198. Which of the statement is correct?


A) The JDBC module provides a JDBC-abstraction layer that removes the need to do tedious JDBC related
coding.
B)The ORM module provides integration layers for popular object-relational mapping APIs, including
JPA, JDO, Hibernate, and iBatis.
C)The Java Messaging Service JMS module contains features for producing and consuming messages.
D)All of the above.

199. Can we inject value and ref both together in a bean?


a) True
b) False

200. Beans, Core, Context, SpEL are the modules of core container.
a) true
b) false

201. How can you inject Java Collection in Spring??


A) Using list, set, map or props tag.
B)Using lit, set, map or collection tag.
C)Using list, set, props or collection tag.
D)Using list, collection, map or props tag.
202. Which of the following stands true for spring beans?
A) Spring beans are managed by the Spring IoC container.
B)Spring beans are instantiated, assembled, and otherwise managed by a Spring IoC container.
C)Spring beans are simple POJOs.
D)All of the above.

203. Run advice before and after the advised method is invoked.
ans. around advice

204. 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

205. Needs to be implemented by objects that can resolve views by name.


ANS : ViewResolver

206. The @Transactional annotation allows u to define transactions programmatically.


Ans: FALSE

207. What are the ways to access Hibernate by using Spring?


A) Inversion of Control with a Hibernate Template and Callback.
B)Extending HibernateDAOSupport and Applying an AOP Interceptor node.
C)Both of above.
D)None of above.

208. What are the benefits of Spring Framework's transaction management?


a.It Provides a consistent programming model across different transaction APIs such as JTA,
JDBC, Hibernate, JPA, and JDO.
b.It Supports declarative transaction management.
c.It Provides a simpler API for programmatic transaction management than a number of complex
transaction APIs such as JTA.
d.All the listed

209. Given the following Spring configuration file, what is the correct answer:
<bean class="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao"/>
</bean>
<bean class="com.spring.repository.JpaDao"/>
i. The first declared bean MyServiceImpl is missing an id must be named
myService
ii. The second declared bean JpaDao is missing an id must be named
jpaDao
iii. Answers 1 and 2 are both rights
iv. Answers 1 and 2 are both wrong

220. which of the following are the concerns which are needed in almost every module of an application
a)logging
b)security
c)data transfer

221. Hibernate is the open object relational mapping tool for java.
a)true
b)false

222. which of the following can be values of beans?


a. Bean
b. All
c. Collection(set,list,props,map)
d. Direct values
e. Compound property
223. Which of the following is not a type of mapping
a.Instance mapping
b.Component mapping
c.Association mapping
d.Class mapping

224. Which of the following is true about <property> element?


A) The <property> element is used to map a Java class property to a column in the database table.
B)The name attribute of the element refers to the property in the class.
C)The column attribute of the element refers to the column in the database table.
D)All of the above.

225. In Spring MVC which of the following is the front controller class that initializes the context based
on the spring beans configuration?
a)org.springframework.web.servlet.DispatcherServlet
b)org.springframework.web.context.DispatcherServlet
c)org.springframework.web.servlet
d)org.springframework.web.context.ApplicationContext

226. The central artefact in spring javConfig is the @Configuratuion annotated class?State True or False
a) TRUE
b) FALSE

227. Which of the following situation represents many-to-many relationship?


A) An employee can have multiple certificates and same certificate can be conferred to many
employees.
B)An employee can have multiple certificates.
C)A certificate can be conferred to many employees.
D)All of the above.
228. Session----This scopes a bean definition to an HTTP session only.

229. Which of the following element maps java.util.Map property in hibernate?


A) <Set>
B)<List>
C)<Bag>
D)<Map>

230. Is second level caching mandatory in hibernate?


A) true
B)false

231. In spring MVC each tag provides support to the set of attributes of its corresponding HTML tag
counterpart making the tags familiar & intuitive to use. State true or False.
a) True
b) false

232. Which of the following element maps java.util.Collection property in hibernate?


A) <set>
B)<list>
C)<bag>
D)<map>

233. Which of the following is true about HQL?


A) Hibernate Query Language (HQL) is an object-oriented query language.
B)Instead of operating on tables and columns, HQL works with persistent objects and their properties.
C)Both of the above.
D)None of the above.

234. Length returns number of rows in a column for only string type
a). TRUE
b). FALSE

235. The view interface inhibits the preparation of request and hands the request over to one of the view
technologies in spring. State true or false

a)true

b)false

236. The data required for the request is in which part of spring MVC component?
a)model
b)view
c)controller
d)all

237. <id name="deptId" type="string">


<column name="columnid" length="30"/>
<generatoers/><id/> [/xml]
<id name="deptId" type="string">
<column name="columnid" length="30"/>
<generatoers/><id/> [/xml]
The above is an example of creating which key?
a.DB key
b.Unique key
c.Secondary key
d.Primary key
238. Which of the following is true about <class> element?
A) The <class> elements are used to define specific mappings from a Java classes to the database tables.
B)The Java class name is specified using the name attribute of the class element.
C)The database table name is specified using the table attribute of the class element.
D)All of the above.

239.Which of the following is a many to one relationship


a) many-to-one
b) <many-to-one>
c) None of the list
d) <Manyone>

240. To use Hibernate for multiple databases, Configure multiple sessionFactory instances. State True or
False.
a) True
b) False

241. Which of the following are CORRECT in SQL queries in Hibernate.


I. SQL queries may contain named and positioned parameters, just like Hibernate queries
II. You may express a query in SQL, using createSQLQuery()
III. Hibernate take care of the mapping from result sets to objects
IV. You may call session.connection() and use the JDBC Connection at any time.
select one
a. I, II, and III
b. I, II, and IV
c. I, III, and IV
d. I, II, III, and IV

242.Which scope is a single bean definition to have any number of object instances
Prototype

243. @RequestMapping annotation is used to map a URL either an entire class or to particular handler
method
a) True b) False

244. Beans,Core, Context,spEL are the components in Core container


b) True b) False

245. which of the following method returns the root element of the document in DOM parsing?
a) Node.getFirstChild
b) Node.getLastChild
c) Document.getDocumentElement
d) Node.getRoot

246. Which of the following is true about INSERT CLAUSE in HQL?


A) HQL supports INSERT INTO clause only where records can be inserted from one object to
another object.
B)HQL supports INSERT INTO clause without any restriction.
C)Both of the above.
D)None of the above.

247. Element which can be used to inject a collection of name-value pairs where the name and the value
are both Strings type.
a)<list>
b)<set>
c)<map>
d)<props>

248. Which type of annotation applies to bean property setter methods?


a)@Requires
b)@Resource
c)@Required
d)@Requiring

249. Which of the following tools/frameworks provides integration with Hibernate?


A) XDoclet Spring
B)J2EE
C)Maven
D)All of the above.

250. Which of the following is true about <id> element?


A) The <id> element maps the unique ID attribute in class to the primary key of the database table.
B)The name attribute of the id element refers to the property in the class.
C)The column attribute of the id element refers to the column in the database table.
D)All of the above.

251. what are the extension interface are there in hibernate?


a)ConnectionProvider interface
b)ProxyFactory interface
c)Transaction interface
d)Cache interface
e)all

252. which of the following is Hibernate?


a.Lightweight
b.Open Source
c.ORM
d.All of the listed

253. In how many ways, objects can be fetched from database in hibernate?
Hibernate provides following four ways to fetch objects from database:
a. Using HQL
b. Using identifier
c. Using Criteria API
d. Using Standard SQL

254.You would need one session factory object per database using a separate config file.
a) TRUE
b) FALSE

255. IOC container is responsible to:


 create the instance
 configure the instance, and
 assemble the dependencies

256. Which elements not supported by hql?


A.sub
B.where
C.having
D.select

257. What does hibernate batch update and delete do?


a.doesnt effect any versioning columns(update only);
b.can only be against a single object type;
c.understands the instance;
d.data is modified directly in db.
e. all of above

258. does sessionLocaleResolver interceptor detects if a special parameter is present in current Http req?
No

259. Which of the following are true about ‘clean' maven life cycle
a.used to build the application
b.generates site documentaion for the project
c.cleans up artefacts created by prior builds
d.none

260.J2EE integration with hibernate is very difficult.


a) TRUE
b) FALSE

261. Which clause allows you to narrow the list of instances returned?
a) Aggregate function
b) Where clause
c) Select clause
d) joins

262. Constructor injection is difficult to inject. State True or False (doubt)


a) TRUE

b) FALSE

263. Which of the following great future if you can manage in long term?
A) constructor injection

B) schema mapping

C) classpath prefix

D) autowiring

264. Session.beginTransaction method begins a unit of work and returns the associated Transaction object.
A) true
B)false
265. How many bean scopes are specified in singleton by default?
a.6
b.7
c.5
d.none

266. Hibernate inhibits you to express queries in its own portable SQL extension (HQL)as well as in native
SQL ,or with an object oriented criteria
a)true
b)False

267. Tags generated by form tag lib are compliant with xhtml-1.0 strict specification and attendant dtd.
a) True
b) false

268. Archetype is a maven plugin whose task is to create a project structure as per its template
c) True
d) false

269. how do u provide configuration metadata to spring container?


a.xml based config fle
b.annotation based config
c.java based config

270. Spring applications is tightly coupled because of dependency injection


a)True
b)False

271. Named queries are created via which level of annotations on entities?
a.all-level
b.high-level
c.low
d.class level

272. The SessionFactory is heavyweight object.


A) false
B ) true

273. What is the difference between get() and load() methods of session object?
A) get() returns null if no data is present where as load throws ObjectNotFoundException exception in such
case.
B)get() always hits the database whereas load() method doesn't hit the database.
C)get() returns actual object whereas load() returns proxy object.
D)All of the above.

274. The test module supports the testing of spring components with junit for testing
a) True
b) false

275. In controller which is responsible for rendering the page in spring mvc(not sure)
a.browser
b.http
c.database
d.application

276. XML Schema-based configuration introduced in Spring 2.0

277. Spring can organize which type of objects?


a.application layer
b.database layer
c.network
d.browser

278. Which is not a module in spring framework? (ORM/DAO/MVC/none)----none

279. Hibernate is an open ORM tool for java(t/f)-----true


280. Which element of hbm.xml automatically generate the primary key values?
A) id
B)generator
C)primaryKey
D)None of the above.

281.The Spring MVC pattern does not separate the different aspects of the application into input logic,
business logic, and UI logic.
a) true
b) false

282.use of addclass function


a) it is used to convert java class name into file name
b) with the file name, input stream, reader will be processed
c) using add class, other classes will be used efficiently.

283.Constructors in a class can be?


a. may be defined as private
b. Contains same name as class
c. used to create objects
d. all the above

284. Spring is tightly coupled framework using DI.


a) True
b) False

285. Which is correct?


a. Hibernate is an object oriented query language
b. It is database independent
c. it supports pagination
d. HQL statements will be converted to SQL or other language the database supports
e. all the above

286. Which State does data contains---------- model

287. Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?
execution(public * *(..))
a. The execution of all public method
b. The execution of all public method returning a value
c. The execution of all public method having at least one parameter
d. The execution of all public method in class belonging to the default java package

288. Identify the annotation which simply indicates that the affected bean property must be populated at
configuration time, through an explicit property value in a bean definition or through autowiring. The
container throws BeanInitializationException if the affected bean property has not been populated.

@Required

289 What ORM stands for?


A) Object Relation Map
B)Object Relational Mapping
C)Object Record Mapping
D)None of the above.
290 Which of the following is true about configuration component of Hibernate?
A) The Configuration object is the first Hibernate object you create in any Hibernate application.
B)The Configuration object is usually created only once during application initialization.
C)The Configuration object represents a configuration or properties file required by the Hibernate.
D)All of the above.

291 Session.createQuery creates a new instance of Query for the given HQL query string.
A) True
B)False

292. Which element of hbm.xml defines maps the unique ID attribute in class to the primary key of the
database table?
A) Id
B)Generator
C)Primary Key
D)None of the above.

293. Which of the following element maps java.util.SortedMap property in hibernate?


A) <set>
B)<list>
C)<bag>
D)<map>

294. What is lazy loading?


A) Lazy loading is a technique in which objects are loaded on demand basis.
B)Lazy loading is a technique in which objects are persisted on demand basis.
C)Both of the above.
D)None of the above.

295. What is first level cache in hibernate?


A) The first-level cache is the Session based cache.
B)The first-level cache is the SessionFactory based cache.
C)Both of the above.
D)None of the above.

296. When a Transactional concurrency strategy is to be used?


A) Use it for reference data only.
B)Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.
C)Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern.
D)None of the above.

297. Which of the following is a core component of Hibernate?


A) Transaction
B)SessionFactory
C)Session
D)All of the above

298. Which of the following is true about @GeneratedValue annotation?


A) @GeneratedValue annotation takes two parameters strategy and generator.
B)@GeneratedValue annotation provides the primary key generation strategy to be used.
C)Both of the above.
D)None of the above.

299. Which of the following is not an ORM framework?


A) Castor
B)Spring DAO
C)Hibernate
D)NoSQL
300. Which of the following is true about SessionFactory object in hibernate?
A) The SessionFactory is heavyweight object.
B)SessionFactory object is created during application start up and kept for later use.
C)You would need one SessionFactory object per database using a separate configuration file.
D)All of the above.

301. Which of the following is true about transient state of a persistent entity?
A) A new instance of a persistent class which is not associated with a Session
B)A new instance of a persistent class which has no representation in the database.
C)A new instance of a persistent class which has no identifier value.
D)All of the above.

302. Which method is used to re-read the state of the given instance from the underlying database?
A) Session.refresh()
B)Session.get()
C)Session.reload()
D)Session.retrieve()

303. Which of the following element maps java.util.List property in hibernate?


A) <set>
B)<list>
C)<bag>
D)<map>

304. Child objects are not loaded when parent is loaded/populated from database. What this technique is
called?
A) Eager Loading
B)Lazy Loading
C)Request based Loading
D)None of the above.

305. What HQL stands for?


A) Hibernate Query Language
B)High Query Language
C)Hybrid Query Language
D)None of the above.

306. Form tags are available in springs is more compatible with html tags for better development
State True or False
a) true
b) false

307. A Session is used to get a physical connection with a database.


A) true
B)false

308. Which of the following is true about HQL?


A) Hibernate supports named parameters in its HQL queries.
B)HQL supports a range of aggregate methods, similar to SQL.
C)Both of the above.
D)None of the above.

309. Which of the following is true about hibernate. Dialect property in hibernate configuration?
A) This property makes Hibernate generate the appropriate SQL for the chosen database.
B)This property makes Hibernate generate the appropriate java code for the chosen database.
C)Both of the above.
D)None of the above.
310. Which method is used to save the state of the given instance from the underlying database?
A) Session. Store ()
B)Session. Keep ()
C)Session. Save ()
D)Session. Load ()

311. Which of the following is correct about dependency injection?


A) It helps in decoupling application objects from each other.
B)It helps in deciding the dependencies of objects.
C)It stores objects states in database.
D)It stores object states in file system.

312. Configure single sessionFactory per database, using separate configuration file.

a) True
b) False

313. When a Read-write concurrency strategy is to be used?


A) Use it for reference data only.
B)Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.
C)Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical concern.
D)None of the above.

314. What is Advice?


A) This is the way to instruct object to behave in certain manner.
B)This is used to inject values in objects.
C)This is the actual action to be taken either before or after the method execution.
D)This is not invoked during program execution by Spring AOP framework.

315. What is Introduction?


A) An introduction represents a point in your application where you can plug-in AOP aspect.
B)This is used to inject values in objects.
C)This is not invoked during program execution by Spring AOP framework.
D)An introduction allows you to add new methods or attributes to existing classes.

316. How to use ref keyword in beans.xml?


A) Using setter method only.
B)Using constructor argument only.
C)Using setter method and constructor argument both.
D)None of the above.

317. By default a bean is eagerly loaded.


A) False
B)True

318.A bean must have id attribute in beans configuration file.


A) True
B)False

319. What is a DispatcherServlet?


A) DispatcherServlet is used for transaction management.
B)DispatcherServlet is used for AOP.
C)DispatcherServlet handles all the HTTP requests and responses.
D)DispatcherServlet is used for Dependency injection.

320. Which of the statement is not correct?


A) Core and beans modules provide the fundamental parts of the framework, including Dependency
Injection feature.
B)The SpEL module provides a powerful Expression Language for querying and manipulating an object
graph at runtime.
C)Aspects module provides integration with AspectJ.
D)None of the above.

321. What is singleton scope?


A) This scopes the bean definition to a single instance per Spring IoC container.
B)This scopes the bean definition to a single instance per HTTP Request.
C)This scopes the bean definition to a single instance per HTTP Session.
D)This scopes the bean definition to a single instance per HTTP Application/ Global session.

322. Which of the following object is used to create SessionFactory object in hibernate?
A) Configuration
B)Session
C)SessionFactory
D)Transaction

323. What is Weaving?


A) Weaving is the process of injecting values in objects to create an advised object.
B)Weaving is the process of linking aspects with other application types or objects to create an
advised object.
C)This is used to inject values in objects.
D)Weaving is used to check object dependencies.

324. Which ORM Spring supports ?


A) Hibernate
B)iBatis
C)JPA
D)All of above.

325. How to handle shut down of IoC container?


A) Using shutdownHook()
B)Using shutdownHandler()
C)Using registerHook()
D)Using registerShutdownHook()

326. Which of the following class can be used to execute Sql queries in spring?
A)JdbcTemplate
B) JDBCHelper
C)DBHelper
D)DBTemplate

327. Which is the correct implementation class of BeanFactory?


A) XmlBeanFactory
B)ClassPathBeanFactory
C)FileSystemBeanFactory
D)AdvancedBeanFactory

328. What is bean autowiring?


A) Autowiring lets Spring resolve collaborators (other beans) for your bean by inspecting the
contents of the BeanFactory without using <constructor-arg> and <property> elements.
B)Autowiring injects values in spring beans.
C)Autowiring injects one bean into another.
D)Autowiring helps in wiring a list of values, allowing duplicates.

329. How to get object of a service in spring framework?


A) Using new keyword
B)Using dependency injection

330. If a bean is scoped to HTTP request, scope is


A) session
B)global-session
C)prototype
D)request

331. Can be bean be configured to have an inner bean?


A) True B)False

332. What is global-session scope?


A) This scopes a bean definition to an HTTP Application/ Global session.
B)This scopes the bean definition to Spring IoC container.
C)This scopes the bean definition to HTTP request.
D)This scopes the bean definition to HTTP Session.

333. What is Target object?


A) A represents a object in your application where you can plug-in AOP aspect.
B)The object being advised by one or more aspects, this object will always be a proxy object, also
referred to as the advised object.
C)This is used to inject values in objects.
D)This is not invoked during program execution by Spring AOP framework.

334. Core container has AOP as one of its module.


A) True B)False

335. Which class is used to map a database row to a java object in spring?
A) ResultSet
B)RowMapper
C)RowSetMapper
D)ResultSetMapper

336. Which are the modules of Data Access/ integration layer?


A) JDBC, ORM, OXM, JMS, Transactions
B)JDBC, ORM, OXM, JMS
C)JDBC, ORM, Web, Beans
D)JDBC, ORM, OXM, JMS

337. Which of the statement is correct?


A) The JDBC module provides a JDBC-abstraction layer that removes the need to do tedious JDBC related
coding
B)The ORM module provides integration layers for popular object-relational mapping APIs, including
JPA, JDO, Hibernate, and iBatis.
C)The Java Messaging Service JMS module contains features for producing and consuming messages.
D)All of the above.

338. What is true about <map> collection configuration elements?


A) This helps in wiring a list of values, allowing duplicates.
B)This helps in wiring a list of values but without any duplicates.
C)This can be used to inject a collection of name-value pairs where name and value can be of any
type.
D)This tag is not supported.

339. What is true about @Autowired annotation?


A) The @Autowired annotation can be used to autowire bean on the setter method.
B)This annotation provides more fine-grained control over where and how autowiring should be
accomplished.
C)The @Autowired annotation can be used to autowire bean on the methods with arbitrary names and/or
multiple arguments.
D)All of above.

340. How do you turn on annotation wiring?


A) Add <annotation-context:config /> to bean configuration.
B)Add <annotation-config /> to bean configuration.
C)Add <annotation-context-config /> to bean configuration.
D)Add <context:annotation-config/> to bean configuration.
341. How after-throwing advice works?
A) Run advice after a method execution only if method exits by throwing an exception.
B)Run advice after a class loads only if class throws exception during load time.
C)Run advice after http response is returned with error status.
D)Run advice after http request is processed and an exception occurred.

342. Expression Language/ SpEL was introduced in which version of spring framework.
A) 1.0
B)2.0
C)3.0
D)4.0

343. What are the main advantage(s) for using Spring when writing integration tests?
a) Reuse Spring configuration files of the application
b) Create mock or stub
c) Be able to use the rollback after the test pattern
d) Use dependency injection

344. What is true about <set> collection configuration elements?


A) This helps in wiring a list of values, allowing duplicates.
B)This helps in wiring a list of values but without any duplicates.
C)This can be used to inject a collection of name-value pairs where name and value can be of any type.
D)This can be used to inject a collection of name-value pairs where the name and value are both Strings.

345. What are the different points where weaving can be applied?
A) Compile time, load time
B)Compile time, run time
C)Run time
D)Compile time, load Time, Run time
346. Which of the following is part of Data Access layer in Spring framework?
A) Beans
B)Aspects
C)JMS
D)Context

347. What BeanPostProcessor does?


A) It processes beans once a bean is initialized.
B)It defines callback methods that you can implement to provide your own instantiation logic,
dependency-resolution logic etc.
C)It processes beans once a bean is loaded.
D)It processes beans once a bean exits.

348.Which are the IoC containers in Spring?


A) BeanFactory, ApplicationContext
B)BeanFactory, ApplicationContext, IocContextFactory
C)BeanFactory, BeanContext, IocContextFactory
D)BeanFactory, ApplicationContext, BeanContext

349. What is no mode of autowiring?


A) Default setting which means no autowiring and you should use explicit bean reference for wiring.
B)Autowiring by property name.
C)Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to autowire by
byType.
D)Similar to byType, but type applies to constructor arguments.

350. What is ContextRefreshedEvent event?


A) This event is published when the Servlet Context is either initialized or refreshed.
B)This event is published when the HTTP Request is received.
C)This event is published when the HTTP Response is returned.
D)This event is published when the ApplicationContext is either initialized or refreshed.
351. How after-returning advice works?
A) Run advice after a class loads only if class loads successfully.
B)Run advice after a method execution only if method completes successfully.
C)Run advice after http response is returned only if http response is success.
D)Run advice after http request is processed with no exception.

352. What are the types of the transaction management Spring supports?
A) Programmatic transaction management
B)Declarative transaction management
C)Both of above.
D)None of above.

353. What is true about cross-cutting concerns?


A) The functions that span multiple points of an application are called cross cutting concerns.
B)Cross-cutting concerns are conceptually separate from the application's business logic.
C)Logging is one of the examples of cross cutting concerns.
D)All of the above.

354. What is true about <props> collection configuration elements?


A) This helps in wiring a list of values, allowing duplicates.
B)This helps in wiring a list of values but without any duplicates.
C)This can be used to inject a collection of name-value pairs where name and value can be of any type.
D)This can be used to inject a collection of name-value pairs where the name and value are both
Strings.

355. What is byType mode of autowiring?


A) Default setting which meas no autowiring and you should use explicit bean reference for wiring.
B)Autowiring by property name. Spring tries to match and wire its properties with the beans defined by the
same names in the configuration file.
C)Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to autowire by
byType.
D)Autowiring by property type. Spring tries to match and wire a property if its type matches with
exactly one of the beans name in configuration file.

356. What is Join point?


A) This represents a point in your application which joins two objects.
B)This represents a point in your object where you join values.
C)This represents a point in your object where you join injected values.
D)This represents a point in your application where you can plug-in AOP aspect.

357. Select the right statement about referring a Spring configuration file inside the package
com.example.myapp in the below example?
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:/com.example.myapp.config.xml");(checkbox ques)
a) The classpath: prefix could be omit
b) Package name with dot is not well formatted using the dot character
c) The slash character preceding com.example could be omit
d) All of the above
e) None of the above

358. If a bean can be created any number of times, scope is


A) session
B)global-session
C)prototype
D)request

359. What is spring?


A) Spring is an open source development framework for enterprise Java.
B)Spring is a proprietary framework.
C)Spring is a development framework for .Net applications.
D)Spring is a development framework for PHP based applications.

360. What is prototype scope?


A) This scopes a single bean definition to have any number of object instances.
B)This scopes the bean definition to a single instance per HTTP Request.
C)This scopes the bean definition to a single instance per HTTP Session.
D)This scopes the bean definition to a single instance per HTTP Application/ Global session.

361. What does @Required annotation mean?


A) This annotation indicates that bean property must be populated by the user.
B)This annotation indicates that bean property is required while saving the bean data to database.
C)This annotation simply indicates that the affected bean property must be populated at
configuration time, through an explicit property value in a bean definition or through autowiring.
D)This annotation indicates that bean property is required while serializing the bean.

362. How before advice works?


A) Run advice before a class loads.
B)Run advice before a method execution.
C)Run advice before http response is to be returned.
D)Run advice before http request is to be processed.

363. Which of the following database is not supported using jdbcTemplate?


A) MySql
B)PostgresSql
C)NoSql
D)Oracle
364. What is the scope of stateless bean?
A) global-session
B)singleton
C)prototype
D)request

365. Which are the modules of core container?


A) Beans, Core, Context, SpEL
B)Core, Context, ORM, Web
C)Core, Context, Aspects, Test
D)Bean, Core, Context, Test

366. What is/are typically case(s) where you usually need to manually instantiated an ApplicationContext?

a) In a web application

b) In an integration test running with the SpringJUnit4ClassRunner

c) In a standalone application started with a main method

d) None of the above

367. What is aspect?


A) Aspect is a way to do the dependency injection.
B)A module which has a set of APIs providing cross-cutting requirements.
C)Aspect is used to log information of application.
D)Aspect represents properties of spring based application.

368. What are the types of advice?


A) then, after, after-returning, after-throwing, around
B)When, after, after-returning, around
C)Where, after, after-returning, after-throwing, around
D)Before, after, after-returning, after-throwing, around
367. Can we integrate Struts with Spring.
A) Yes
B)No

368. Which are the different modes of autowiring?


A) no, byName, byType, constructor, autodetect
B)no, byName, byType, constructor, autocorrect
C)byName, byContent, constructor, autodetect
D)byName, byContent, setter, autodetect

369. By default a bean is eagerly loaded.


A) False B)True

370. Where do you define DispatcherServlet?


A) In Beans configuration file.
B)Web.xml file
C)Meta-inf/dispatcher.xml
D)Web-inf/ dispatcher.xml

371. What is true about BeanPostProcessor?


A) It is a concrete class.
B)It is an interface.
C)It is an abstract class.
D)None of the above.

372. Hibernate session is the main runtime interface between java applications and hibernate.
a) TRUE b) FALSE
373. Which of the following is true about @Column annotation?
A) The @Column annotation is used to specify the details of the column to which a field or property will
be mapped.
B)The @Column annotation is applied on a class.
C)Both of the above.
D)None of the above.

374. What is @Controller annotation?


A) The @Controller annotation indicates that a particular class serves the role of a controller.
B)The @Controller annotation indicates how to control the transaction management.
C)The @Controller annotation indicates how to control the dependency injection.
D)The @Controller annotation indicates how to control the aspect programming.

375. What is ACID in transactional management?


A) Accurate, Controlled, Isolation, Durability
B)Atomicity, Consistency, Independent, Done
C)Atomicity, Consistency, Isolation, Durability
D)Accurate, Controlled, Independent, Done

376. What is RequestHandledEvent:event?


A) This event is published when the Servlet Context is either initialized or refreshed.
B)This event is published when the HTTP Request is received.
C)This event is published when the HTTP session is initialized or refreshed.
D)This event is published when the HTTP Request is serviced.

377. Application contexts provide a generic way to load file resources, such as images.
a) True
b) False
378. What is easier to do by using Spring JMS support? Select one or more correct answers.
a. Register any Spring bean as JMX MBean
b. Register an existing MBean with a MBeanServer
c. Accessing to remote MBean
d. Control the attributes and the operations of a Spring bean exposes as a MBean

379. What is the scope of bean in portlet context?


A) session
B)global-session
C)prototype
D)request

380. What is autodetect mode of autowiring?


A) Similar to byType, but type applies to constructor arguments. If there is not exactly one bean of the
constructor argument type in the container, a fatal error is raised.
B)Autowiring by property name. Spring tries to match and wire its properties with the beans defined by the
same names in the configuration file.
C)Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.
D)Autowiring by property type. Spring tries to match and wire a property if its type matches with exactly
one of the beans name in configuration file.

381. What is Pointcut?


A) This represents a point in your application where you can plug-in AOP aspect.
B)This is a set of one or more joinpoints where an advice should be executed.
C)This is used to inject values in objects.
D)This is invoked during program execution by Spring AOP framework.

382. Which class acts as IoC Container?


A) ServletContext
B)DispatcherServlet
C)ApplicationContext
D)None of the above

383. What is constructor mode of autowiring?


A) Autowiring by property name. Spring tries to match and wire its properties with the beans defined by
the same names in the configuration file.
B)Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to autowire by
byType.
C)Autowiring by property type. Spring tries to match and wire a property if its type matches with exactly
one of the beans name in configuration file.
D)Similar to byType, but type applies to constructor arguments. If there is not exactly one bean of
the constructor argument type in the container, a fatal error is raised.

384. How bean life cycle can be controlled?


A) Using init() only
B)Using InitializingBean class only
C)Using DisposableBean class only
D)Using All of above

385. Which of the following class can be used to call Stored Procedures in spring?
A) SPHelper
B)JdbcTemplateCall
C)JdbcTemplate
D)SimpleJdbcCall

386. Which element of hbm.xml is used to map a Java class property to a column in the database table?
A) id
B)generator
C)property
D)class

387. How around advice works?


A) Run advice before and after the advised method is invoked.
B)Run advice before and after a class is loaded.
C)Run advice before and after http response is returned.
D)Run advice before and after http request is processed.

388. validation, rejectIfEmptyOrWhiteSpace or rejectIfEmpty is used- True

389. Cache is simply to enhance the performance and it sits between application and database.
a) True
b) False

390.Hibernate helps in mapping of java objects with database tables


a) true
b) false

391. Scope that are used only in web aware application context
 Request
 Session
 Global session

392. What is Query level cache in hibernate?


A) The query-level cache is cache for query result sets that integrates closely with the second-level
cache.
B)The query-level cache is the Session based cache.
C)Both of the above.
D)None of the above.

393. Which of the following is a concurrency strategy in hibernate?


A) Transactional
B)Read-write
C)No strict-read-write.
D)All of the above.

394. Which of the following is true about @Id annotation?


A) Hibernate detects that the @Id annotation is on a field.
B)Hibernate assumes that it should access properties on an object directly through fields at runtime.
C)Both of the above.
D)None of the above.

395. Which of the following is true about HQL?


A) HQL queries are translated by Hibernate into conventional SQL queries which in turns perform action
on database.
B)The AS clause can be used to assign aliases to the classes in HQL queries.
C)Both of the above.
D)None of the above.

396. Which of the following is true about ORM?


A) ORM stands for Object-Relational Mapping.
B)ORM is a programming technique for converting data between relational databases.
C)Both of the above.
D)None of the above.

397. Which of the following is true about Query object in hibernate?


A) Query objects Hibernate Query Language (HQL) string to retrieve data from the database and create
objects.
B)Query objects SQL string to retrieve data from the database and create objects.
C)A Query instance is used to bind query parameters, limit the number of results returned by the query, and
finally to execute the query.
D)All of the above.

398. Session.createSQLQuery creates a new instance of Query for the given SQL query string.
A) true
B)false

399. Which method is used to get a persistent instance from the datastore?
A) Session.read()
B)Session.get()
C)Session.retrieve()
D)Session.fetch()

400. Which of the following is true about <generator> element?


A) The <generator> element within the id element is used to automatically generate the primary key values
B)Set the class attribute of the generator element is set to native to let hibernate pick up either identity,
sequence or Hilo algorithm to create primary key depending upon the capabilities of the underlying
database.
C)Both of the above.
D)None of the above.

401. Which of the following element is used to represent one-to-many relationship in hibernate?
A) <one-to-many>
B)<one-many>
C)<OneToMany>
D)None of the above.

402. Is query level caching mandatory in hibernate?


A) true
B)false

403. When a Read-only concurrency strategy is to be used?


A) Use it for reference data only.
B)Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent transactions.
C)Use this strategy if data hardly ever changes and a small likelihood of stale data is not of critical
concern.
D)None of the above.

404. Which of the following is true about hibernate annotations?


A) Hibernate Annotations is the powerful way to provide the metadata for the Object and Relational Table
mapping.
B)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.
C)Both of the above.
D)None of the above.

405. Which of the following is not a core component of Hibernate?


A) JDBC
B)SessionFactory
C)Session
D)Configuration

406. Is Session a thread-safe object?


A) true
B)false

407. Which method is used to remove a persistent instance from the datastore?
A) Session.delete()
B)Session.remove()
C)Session.del()
D)Session.rm()

408. Which method is used to save or update the state of the given instance from the underlying database?
A) Session.saveOrUpdate()
B)Session.keep()
C)Session.update()
D)Session.load()

409. Is first level caching mandatory in hibernate?


A) true
B)false

410.which of the following is an invalid annotation?


a) @RequestParam
b) @PathValid
c) @Responsevalid
d) @RequestMapping

411. POM file should contain versionID, groupID, ArtifactId--------- True

412. Types of aspect implementation


 XML schema based
 Java Based
 @AspectJ based

413. How could you implement a JMS Listener using the Spring JMS support? Select one or more correct
answers.
a. By implementing the javax.jms.MessageListener interface
b. By implementing the SessionAwareMessageListener interface provided by Spring
c. Without any code, only using the jms namespace provided by Spring
d. By writing a single POJO without parent class or interface

414. Which of the following is true about Transaction object in hibernate?


A) A Transaction represents a unit of work with the database.
B)Transactions in Hibernate are handled by an underlying transaction manager.
C)This is an optional object and Hibernate applications may choose not to use this interface, instead
managing transactions in their own application code.
D)All of the above

415. What do you have to do even if you are using the RMI Spring Remoting support? Select one or more
correct answers.
a. Implements the Remote interface
b. Extends the RemoteObject class
c. Catching the RemoteException exception
d. Implements the Serializable interface

416. What is a view resolver?


a) class
b) interface
c) object
d) argument

417. Model is used to encapsulate the response data


a) true
b) false

418. Which one interpret user input and transform it into a model that is represented to the user by the
view.
a) controller
b) dispatcher servlet
c) model
d) browser

419. Which one runs advice before and after the advised method is invoked.
a) after
b) before
c) around
d) none of the above

420. Length attribute of @column annotation permits the size of the column used to map a value
particularly for a string value.
a) true b)false

421. Application contexts can publish events to beans that are registered as listeners.
a)true
b)false

422. which is not used as java annotation


a) @component
b) @bean
c) @configuration
d) none

423. What the three inheritance models of hibernate?


Hibernate has following three inheritance models:
a. Tables Per Concrete Class
b. Table per class hierarchy
c. Table per sub-class

424. To use spring MVC validator, which of the following is used to start the validator?- ve to select more than
1 so I chose al the check box..

A) override supports

B) override validate

C) override validator

D) override creates
425. index and type can be used in the constructor-arg at the same time?
State True or False
a)TRUE
b) FALSE

426. Spring offers four types of collection configuration elements.


 List
 Set
 Map

427. Which of the following database is supported by Hibernate?


A) DB2/NT
B)PostgreSQL
C)Sybase SQL Server
D)All of the above

428. Configuration object is used to create SessionFactory object in hibernate.


A) true
B)false

429. Which of the following is the root node of hbm.xml file?


A) hibernate-mapping
B)hibernate-config
C)class-mapping
D)class-config

430. What is exact about the HttpInvokerServiceExporter? Select one or more correct answers.
a. Has to run into a HTPP server as Jetty
b. Could process both POST and GET requests
c. Could be used with any http client as Jakarta Commons HttpClient
d. Could consume SOAP http request

431. What is the method that is not provided by the JmsTemplate Spring class?
a. convertAndSend
b. onMessage
c. receiveAndConvert
d. setDefaultDestination

432. How is named the bean that is defined in the following configuration class. Select a single answer.
@Configuration
public class ApplicationConfig {
@Autowired
private DataSource dataSource;
@Bean
ClientRepository clientRepository() {
ClientRepository accountRepository = new JpaClientRepository();
accountRepository.setDataSource(dataSource);
return accountRepository;
}
}
1. JpaClientRepository
2. jpaClientRepository
3. clientRepository
4. Two beans are defined : a data souce and a repository

433. How could you externalize constants from a Spring configuration file or a Spring annotation into a
.properties file? Select one or more answers
a. By using the <util:constant /> tag
b. By declaring the ConstantPlaceholderConfigurer bean post processor
c. By using the <context:property-placeholder /> tag
d. By using the c: namespace

434. What is the purpose of the @ManageResource annotation? Select a single answer.
a. Expose a bean’s property (getter/setter) to JMX
b. Expose a bean’s method to JMX
c. Identify a Spring bean as a JMX MBean
d. None of the above

435. What are the right affirmations about the @PostConstruct, @Resource and the @PreDestroy
annotations?
a. Those annotations are specified in the JSR-250
b. The Spring Framework embedded those annotation
c. The <context:component-scan> tag enable them
d. The <context:annotation-config > tag enable them
e. Declaring the CommonAnnotationBeanPostProcessor enable them

436. What is/are typically case(s) where you usually need to manually instantiated an ApplicationContext?
a. In a web application
b. In an integration test running with the SpringJUnit4ClassRunner
c. In a standalone application started with a main method
d. None of the above

437.Select the right statement about referring a Spring configuration file inside the package
com.example.myapp in the below example?
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:/com.example.myapp.config.xml");
a) The classpath: prefix could be omit
b) Package name with dot is not well formatted using the dot character
c) The slash character preceding com.example could be omit
d) All of the above
e) None of the above

438. How to auto-inject into a field a bean by its name? Select one or more response.
a) With the name attribute of the @Autowired annotation
b) By using the single @Qualifier annotation
c) By using both the @Autowired and the @Qualifier spring annotations
d) By using the @Autowired annotation and naming the field with the bean name

439. What are the main advantages of using interfaces when designing business services? Select one or
more answers.
a. Mocking or stubbing the service
b. Be able to use the Spring auto-injection
c. Can do dependency checking
d. Loosely coupled code

440. Select one or many correct answers about spring bean life cycle.
1. The method annoted with @PostConstruct is called after bean instantiation and before
properties setting of the bean
2. The method @PreDestroy of a prototype bean is called when the bean is garbage collected
3. The init() method declared in the init-method attribute of a bean is called before the
afterPropertiesSet callback method of the InitializingBean interface
4. The method annotated with @PostConstruct is called before the afterPropertiesSet
callback method of the InitializingBean interface

441. Given the following configuration class, what are correct affirmations? Select one or more answers.
public class ApplicationConfig {
private DataSource dataSource;
@Autowired
public ApplicationConfig(DataSource dataSource) {
this.dataSource = dataSource;
}
@Bean(name="clientRepository")
ClientRepository jpaClientRepository() {
return new JpaClientRepository();
}
}
a. @Configuration annotation is missing
b. Default or no-arg constructor is missing
c. @Bean name is ambiguous
d. @Bean scope is prototype

442. What are the features of the XML <context: namespace? Select one or many answers.
1. @Transactional annotation scanning
2. @Aspect annotation detection enabling
3. @Autowired annotation enabling
4. @Component annotation scanning
443. Select one or more correct statements about developing integration test with Spring support.
a) A new Spring context is created for each test class
b) To get a reference on the bean you want to test, you have to call the getBean() method of
the Spring context
c) Spring context configuration could be inherits from the super class
d) The Spring context configuration file has to be provided to the @ContextConfiguration annotation

444.What are the main advantage(s) for using Spring when writing integration tests?
a. Reuse Spring configuration files of the application
b. Create mock or stub
c. Be able to use the rollback after the test pattern
d. Use dependency injection

445.What are the main advantage(s) for using Spring when writing unit tests?
a. Reuse Spring configuration files of the application
b. Use dependency injection
c. Provide some mocks for servlet classes
d. All of the above
e. None of the above

446. What is right about the spring test module?


a. It provides an abstraction layer for the main open source mock frameworks
b. Provides the @Mock annotation
c. It dynamically generates mock objects
d. All of the above
e. None of the above

447.Select correct statement(s) about transactional support of the spring test module.
1. Transaction manager could be set within the @TransactionConfiguration annotation
2. Method annotated with @Before is executed outside of the test’s transaction
3. Spring test may rollback the transaction of a service configured with the REQUIRES_NEW
propagation
4. The transaction of a method annotated with the @Rollback annotation with its default
values is rolled back after the method has completed

448. Considering 2 classes AccountServiceImpl and ClientServiceImpl. Any of these 2 classes inherits from
each other. What is the result of the pointcut expressions?
execution(* *..AccountServiceImpl.update(..))
&& execution(* *..ClientServiceImpl.update(..))
1. Matches pubic update methods of the 2 classes, whatever the arguments
2. Matches any update methods of the 2 classes , whatever the arguments and method
visibility
3. Matches any update methods of the 2 classes , with one more arguments and whatever
method visibility
4. No joint point is defined

449. Using the Spring AOP framework, what is the visibility of the method matches by the following join
point?
@Pointcut("execution(* *(..))")
private void anyOperation() {};
1. All methods, whereas there visibility
2. All methods, except private method
3. Protected and public methods
4. Public methods

500. What are the 2 correct statements about AOP proxy?


1. AOP proxies are created by Spring in order to implement the aspect contracts
2. AOP proxies are always created with a JDK dynamic proxy
3. Only classes that implements a least one interface could be proxied
4. All methods could be proxied
5. Proxies are created by a BeanPostProcessor

501. What is an after throwing advice? Select a unique answer.


1. Advice that could throw an exception
2. Advice to be executed if a method exits by throwing an exception
3. Advice that executes before a join point
4. Spring does not provide this type of advice

502.What is an after returning advice? Select a unique answer.


1. Advice to be executed regardless of the means by which a join point exits
2. Advice that surrounds a method invocation and can perform custom behavior before and
after the method invocation
3. Advice to be executed before method invocation
4. Advice to be executed after a join point completes without throwing an exception

503.What is an advice? Select a unique answer.


1. An action taken by an aspect at a particular join point
2. A point during the execution of a program
3. An aspect and a pointcut
4. A predicate that matches join points

504. What is a pointcut? Select a unique answer.


1. Code to execute at a join point
2. An expression to identify joinpoints
3. An advice and a jointpoint
4. None of the above

505. Select method’s signatures that match with the following pointcut:
execution(* com.test.service..*.*(*))
1. void com.test.service.MyServiceImpl#transfert(Money amount)
2. void com.test.service.MyServiceImpl#transfert(Account account, Money amount)
3. void com.test.service.account.MyServiceImpl#transfert(Money amount)
4. void com.test.service.account.MyServiceImpl#transfert(Account account, Money amount)
5. None of the above
506. What are the unique correct answers about Spring AOP support?
1. An advice could proxied a constructor’s class
2. A point cut could select methods that have a custom annotation
3. Static initialization code could be targeted by a point cut
4. Combination of pointcuts by &&, || and the ! operators is not supported

507.Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?
execution(public * *(..))
1. The execution of all public method
2. The execution of all public method returning a value
3. The execution of all public method having at least one parameter
4. The execution of all public method in class belonging to the default java package

508.Why is it a best practice to mark transaction as read-only when code does not write anything to the
database? Select one or more answers.
1. It is mandatory for using Spring exception translation mechanism
2. May be improve performance when using Hibernate
3. Spring optimizes its transaction interceptor
4. Provides safeguards with Oracle and some other databases

509.What data access technology is supported by the Spring framework? Select one or more answers.
1. JDBC
2. NoSQL
3. Hibernate
4. JPA

510.What is not provided by the JdbcTemplate? Select a unique answer.


1. Data source access
2. Open/close data source connection
3. JDBC exception wrapping into DataAccess Exception
4. JDBC statement execution
511.Using JdbcTemplate, what is the Spring provided class you will use for result set parsing and merging
rows into a single object? Select a unique answer.
1. RowMapper
2. RowCallbackHandler
3. ResultSetExtractor
4. ResultSetMapper

512.What configuration is supported by the LocalSessionFactoryBean? Select a unique answer.


1. Listing entity classes annoted with @Entity
2. Scanning a package to detect annoted entity classes (with @Entity)
3. Listing hibernate XML mapping configuration file (.hbm.xml)
4. All above

513.What is/are incorrect statements about XML declaration of the transaction manager bean? Select
one or more answers.
1. The tx namespace provides JTA transaction manager declaration shortcut syntax
2. Id of the bean has to be transactionManager
3. Depending the application persistence technology, the HibernateTransactionManager or the
DataSourceTransactionManager could be used as bean class
4. Default transaction timeout could be given

514. Assuming @Transactional annotation support is enabled and the transferMoney method is called
through a Spring AOP proxy, what is the behavior of the following code sample?
@Transactional(propagation=Propagation.REQUIRED)
public void transferMoney(Account src, Account target, double amount) {
add(src, -amount);
add(src, amount);
}
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void add(Account account, Double amount) {
// IMPLEMENTATION
}
a. The add() method executes code in a new transaction
b. The add() method uses the transaction of the transferMoney() method
c. When calling the add() method, an exception is thrown
d. Other behavior

515. Does Spring provides programmatic transaction management? Select a unique answer.
a. Yes with the TransactionTemplate class
b. Yes with the TransactionService class
c. Yes using the @Transactional bean post processor
d. No

516. What is the transaction behavior of the PROPAGATION_REQUIRES_NEW mode? Select a unique
answer.
1. If a transaction exists, the current method should run within this transaction. Otherwise, it
should start a new transaction and run within its own transaction.
2. If a transaction is in progress, the current method should run within the nested transaction
of the existing transaction. Otherwise, a new transaction has to be started and run within its
own transaction.
3. The current method must start a new transaction and run within its own transaction. If there
is an existing transaction in progress, it is suspended.
4. None of the above

517. What is the default rollback policy in transaction management?


a. Rollback for any Exception
b. Rollback for RuntimeException
c. Rollback for checked exceptions
d. Always commit

518. What could not return a Spring MVC controller? Select a single answer.
a. An absolute path to the view
b. A logical view name
c. A new JstlView
d. void
e. null value

519. Where do you cannot declare Spring MVC controller? Select one or more answers.
1. In a Spring application context XML configuration file
2. Into the web.xml file of the web application
3. Into the java code by using annotations
4. Into the JSP pages

520. What is the easiest method to write a unit test?


1. void displayAccount(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
2. void displayAccount(HttpServletRequest req, HttpSession Session)
throws ServletException, IOException
3. @RequestMapping("/displayAccount")
String displayAccount(@RequestParam("accountId") int id, Model model)
4. @RequestMapping("/displayAccount")
String displayAccount(@PathVariable("accountId") int id, Model model)

521.How could you secure MVC controller with Spring Security? Select a unique answer.
a) With the @Secured annotation
b) With the @RolesAllowed annotation
c) In a XML security configuration file
d) All of the above
e) None of the above

522. What are the possible mechanisms provided by Spring Security to store user details? Select one or
more correct answers.
a. Database
b. JAAS
c. LDAP
d. Properties file

523. What is true about Spring security configuration and the security namespace? Select one or more
correct answers.
a. The access attribute of the intercept-url tag support both EL and constants together.
b. The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is
b) the first that matches.
a. The patterns declared into the intercept-url tag use by default the java regex syntax.
b. Security rules may applied depending request parameter

524. A many-to-one association is the most common kind of association where an object can be associated with
multiple objects.
a)true
b)false

525. what does hibernate do in the listed options?


a) Guaranteed uniqueness of object
b) Transparent persistence
c) Persistence of association and collection
d) Object relational mapping
e) all

526. The bean in the xml file is important for specifying the view resolver and view components
a)true
b)false

527. Spring security framework focuses on which of the following?


a) Providing authorization in java applications
b) Providing authentication in java applications
c) Providing both authorization and authentication in java application
d) None

528. Spring provides @Validator annotation and Binding Result class through which we can get the errors
raised by Validator implementation in the controller request handler method.
A)true
B)false

529. spring has which of the ways to minimize XML in spring.config.xml?


a) Using auto wiring
b) All
c) Using Auto-Discovery of beans
d) Using java based configuration

530.spring provides a comprehensive set of data binding-aware tags for handling form elements when
using JSP and spring web MVC
a)true
b)false

531.how do you define the scope of a bean


a) When defining a <bean> in a spring we can declare the scope of a bean
b) It can be defined through scope attribute in the bean definition
c) The bean scope attribute must be set to prototype

532.which of the following statements are false?


a)The ORM package provides integration layers for popular ORM API’s including JPA,JDO,hibernate and
iBatis
b)None
c) The core package is the most fundamental part of the framework and provides Ioc and dependency
injection features

533.SessionFactory allows application to create hibernate session by reading hibernate configuration file
hibernate.cfg.xml
a)true
b)false

534.which of the activities does data filtering do?


a) Often used for security purpose
b) Limit the amount of invisible data by modifying query parameters
c) Users often only have access to certain level of information
d) Similar to label security in database

535.which of the following define why spring is necessary?


a) All framework have difficulty to integrate with spring
b) Easier to test application
c) Spring framework is unstructured using dependency injection
d) Less complicated than other framework

536. to create new xml configuration extension which of the following are relatively simple steps
a)all
b)coding one or more BeanDefinitionParser implementation
c)coding a custom NamespaceHandler implementation
d)authoring an XML schema to describe your custom elements
e)registering all artefacts with the spring

537. which of the following statements are view resolver pattern and works in spring MVC?
a)it is a J2EE pattern which allows a web application to dynamically choose a view technology
b) spring MVC framework supplies inbuilt view resolver for selecting view
c)view resolver holds mapping of different views ,controller return the name of the view which is
then passed to the view resolver for a appropriate view
d)its does not support HTML, JSP, Tapestry, JSF and other controller technologies
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST I

Q 1 - What JDBC stands for?

A - Java DB Connectivity

B - Java Database Connectivity

C - Java Data Bind Connect

D - Java Data Bind Connector

Q 2 - Which of the following is true about JDBC?

A - JDBC stands for Java Database Connectivity.

B - JDBC provides a set of Java API for accessing the relational databases from Java program.

C - JDBC APIs enables Java programs to execute SQL statements and interact with any SQL
compliant database.

D - All of the above.

Q 3 - What ORM stands for?

A - Object Relation Map

B - Object Relational Mapping

C - Object Record Mapping

D - None of the above.

Q 4 - Which of the following is true about ORM?

A - ORM stands for Object-Relational Mapping.


B - ORM is a programming technique for converting data between relational databases.

C - Both of the above.

D - None of the above.

Q 5 - Which of the following is not an ORM framework?

A - Castor

B - Spring DAO

C - Hibernate

D - NoSQL

Q 6 - Which of the following is true about Hibernate?

A - Hibernate is an Object-Relational MappingORM solution for JAVA.

B - Hibernate is an Object-Relational MappingORM solution for .NET

C - Both of the above.

D - None of the above.

Q 7 - Which of the following is true about Hibernate?

A - Hibernate takes care of mapping Java classes to database tables using XML files and without
writing any line of code.

B - Hibernate provides simple APIs for storing and retrieving Java objects directly to and from the
database.

C - Hibernate abstracts away the unfamiliar SQL types and provide us to work around familiar
Java Objects.

D - All of the above.

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

A - DB2/NT

B - MySQL

C - FoundationDB

D - PostgreSQL

Q 9 - Which of the following tools/frameworks provides integration with Hibernate?

A - XDoclet Spring

B - J2EE

C - Maven

D - All of the above.


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

A - JDBC

B - SessionFactory

C - Session

D - Configuration

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

A - Transaction

B - Provider

C - Criteria

D - Query

Q 12 - Which of the following is true about configuration component of Hibernate?

A - The Configuration object is the first Hibernate object you create in any Hibernate application.

B - The Configuration object is usually created only once during application initialization.

C - The Configuration object represents a configuration or properties file required by the


Hibernate.

D - All of the above.

Q 13 - Which of the following object is used to create SessionFactory object in


hibernate?

A - Configuration

B - Session

C - SessionFactory

D - Transaction

Q 14 - Which of the following is true about SessionFactory object in hibernate?

A - SessionFactory object configures Hibernate for the application using the supplied
configuration file.

B - SessionFactory object allows for a Session object to be instantiated.

C - The SessionFactory is a thread safe object.

D - All of the above.

Q 15 - Which of the following is true about SessionFactory object in hibernate?

A - The SessionFactory is heavyweight object.


B - SessionFactory object is created during application start up and kept for later use.

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

D - All of the above.

Q 16 - Which of the following is true about Session object in hibernate?

A - A Session is used to get a physical connection with a database.

B - The Session object is lightweight.

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

D - All of the above.

Q 17 - Is SessionFactory a thread-safe object?

A - true

B - false

Q 18 - Is Session a thread-safe object?

A - true

B - false

Q 19 - Which of the following is true about Transaction object in hibernate?

A - A Transaction represents a unit of work with the database.

B - Transactions in Hibernate are handled by an underlying transaction manager.

C - This is an optional object and Hibernate applications may choose not to use this interface,
instead managing transactions in their own application code.

D - All of the above.

Q 20 - Which of the following is true about Query object in hibernate?

A - Query objects Hibernate Query Language HQL string to retrieve data from the database and
create objects.

B - Query objects SQL string to retrieve data from the database and create objects.

C - A Query instance is used to bind query parameters, limit the number of results returned by
the query, and finally to execute the query.

D - All of the above.

Q 21 - Which of the following is true about hibernate.dialect property in hibernate


configuration?

A - This property makes Hibernate generate the appropriate SQL for the chosen database.

B - This property makes Hibernate generate the appropriate java code for the chosen database.
C - Both of the above.

D - None of the above.

Q 22 - Which of the following is true about transient state of a persistent entity?

A - A new instance of a persistent class which is not associated with a Session.

B - A new instance of a persistent class which has no representation in the database.

C - A new instance of a persistent class which has no identifier value.

D - All of the above.

Q 23 - Which of the following is true about persistent state of a persistent entity?

A - You can make a transient instance persistent by associating it with a Session.

B - A persistent instance has a representation in the database.

C - A persistent instance has an identifier value.

D - All of the above.

Q 24 - Which of the following is true about detached state of a persistent entity?

A - Once we close the Hibernate Session, the persistent instance will become a detached
instance.

B - A new instance of a persistent class which is not associated with a Session.

C - You can make a transient instance detached by associating it with a Session.

D - None of the above.

Q 25 - Session.beginTransaction method begins a unit of work and returns the


associated Transaction object.

A - true

B - false

ANSWER SHEET

Question Number Answer Key

1 B

2 D

3 B

4 C

5 D

6 A
7 D

8 C

9 D

10 A

11 B

12 D

13 A

14 D

15 D

16 D

17 A

18 B

19 D

20 D

21 A

22 D

23 D

24 A

25 A

Loading [MathJax]/jax/output/HTML-CSS/jax.js
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST II

Q 1 - Session.createCriteria creates a new Criteria instance, for the given entity class,
or a superclass of an entity class.

A - true

B - false

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

A - true

B - false

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

A - true

B - false

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

A - true

B - false

Q 5 - Which method is used to remove a persistent instance from the datastore?

A - Session.delete

B - Session.remove
C - Session.del

D - Session.rm

Q 6 - Which method is used to get a persistent instance from the datastore?

A - Session.read

B - Session.get

C - Session.retrieve

D - Session.fetch

Q 7 - Which method is used to re-read the state of the given instance from the
underlying database?

A - Session.refresh

B - Session.get

C - Session.reload

D - Session.retrieve

Q 8 - Which method is used to save the state of the given instance from the
underlying database?

A - Session.store

B - Session.keep

C - Session.save

D - Session.load

Q 9 - Which method is used to update the state of the given instance from the
underlying database?

A - Session.store

B - Session.keep

C - Session.update

D - Session.load

Q 10 - Which method is used to save or update the state of the given instance from
the underlying database?

A - Session.saveOrUpdate

B - Session.keep

C - Session.update

D - Session.load
Q 11 - Which of the following is the root node of hbm.xml file?

A - hibernate-mapping

B - hibernate-config

C - class-mapping

D - class-config

Q 12 - Which of the following elements is used to define specific mappings from a Java
classes to the database tables?

A - property

B - hibernate-config

C - class

D - class-config

Q 13 - Which of the following is true about <class> element?

A - The <class> elements are used to define specific mappings from a Java classes to the
database tables.

B - The Java class name is specified using the name attribute of the class element.

C - The database table name is specified using the table attribute of the class element.

D - All of the above.

Q 14 - Which element of hbm.xml defines maps the unique ID attribute in class to the
primary key of the database table?

A - id

B - generator

C - primaryKey

D - None of the above.

Q 15 - Which of the following is true about <id> element?

A - The <id> element maps the unique ID attribute in class to the primary key of the database
table.

B - The name attribute of the id element refers to the property in the class.

C - The column attribute of the id element refers to the column in the database table.

D - All of the above.

Q 16 - Which element of hbm.xml automatically generate the primary key values?

A - id
B - generator

C - primaryKey

D - None of the above.

Q 17 - Which of the following is true about <generator> element?

A - The <generator> element within the id element is used to automatically generate the
primary key values

B - Set the class attribute of the generator element is set to native to let hibernate pick up either
identity, sequence or hilo algorithm to create primary key depending upon the capabilities of the
underlying database.

C - Both of the above.

D - None of the above.

Q 18 - Which element of hbm.xml is used to map a Java class property to a column in


the database table?

A - id

B - generator

C - property

D - class

Q 19 - Which of the following is true about <property> element?

A - The <property> element is used to map a Java class property to a column in the database
table.

B - The name attribute of the element refers to the property in the class.

C - The column attribute of the element refers to the column in the database table.

D - All of the above.

Q 20 - Which of the following element maps java.util.Set property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 21 - Which of the following element maps java.util.List property in hibernate?

A - <set>

B - <list>

C - <bag>
D - <map>

Q 22 - Which of the following element maps java.util.Collection property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 23 - Which of the following element maps java.util.Map property in hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 24 - Which of the following element maps java.util.SortedMap property in


hibernate?

A - <set>

B - <list>

C - <bag>

D - <map>

Q 25 - Which of the following element is used to represent many-to-one relationship


in hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above

ANSWER SHEET

Question Number Answer Key

1 A

2 A

3 B

4 A

5 A
6 B

7 A

8 C

9 C

10 A

11 A

12 C

13 D

14 A

15 D

16 B

17 C

18 C

19 D

20 A

21 B

22 C

23 D

24 D

25 A

Loading [MathJax]/jax/output/HTML-CSS/jax.js
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST III

Q 1 - Which of the following element is used to represent one-to-one relationship in


hibernate?

A - <many-to-one>

B - <many-one>

C - <ManyToOne>

D - None of the above.

Q 2 - Which of the following element is used to represent one-to-many relationship in


hibernate?

A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

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

Q 4 - Which of the following element is used to represent one-to-many relationship in


hibernate?
A - <one-to-many>

B - <one-many>

C - <OneToMany>

D - None of the above.

Q 5 - Which of the following situation represents many-to-many relationship?

A - An employee can have multiple certificates and same certificate can be conferred to many
employees.

B - An employee can have multiple certificates.

C - A certificate can be conferred to many employees.

D - All of the above.

Q 6 - What is the difference between save and persist methods of session object?

A - There is no difference.

B - save saves the object and returns status whereas persist stores status in different variable.

C - save saves the object and returns the id of the instance whereas persist do not return
anything after saving the instance.

D - None of the above.

Q 7 - What is the difference between get and load methods of session object?

A - get returns null if no data is present where as load throws ObjectNotFoundException


exception in such case.

B - get always hits the database whereas load method doesn't hit the database.

C - get returns actual object whereas load returns proxy object.

D - All of the above.

Q 8 - What is lazy loading?

A - Lazy loading is a technique in which objects are loaded on demand basis.

B - Lazy loading is a technique in which objects are persisted on demand basis.

C - Both of the above.

D - None of the above.

Q 9 - What is value of lazy loading by default?

A - true

B - false
Q 10 - Child objects are not loaded when parent is loaded/populated from database.
What this technique is called?

A - Eager Loading

B - Lazy Loading

C - Request based Loading

D - None of the above.

Q 11 - What HQL stands for?

A - Hibernate Query Language

B - High Query Language

C - Hybrid Query Language

D - None of the above.

Q 12 - Which of the following is true about HQL?

A - HQL takes java objects in the same way as SQL takes tables.

B - HQL is a Object Oriented Query language

C - HQL is database independent.

D - All of the above.

Q 13 - What is first level cache in hibernate?

A - The first-level cache is the Session based cache.

B - The first-level cache is the SessionFactory based cache.

C - Both of the above.

D - None of the above.

Q 14 - Whis of the following is true about first level cache in hibernate?

A - The first-level cache is the Session cache.

B - The first-level cache is a mandatory cache through which all requests must pass.

C - The Session object keeps an object under its own power before committing it to the database.

D - All of the above.

Q 15 - What is second level cache in hibernate?

A - The second-level cache is the SessionFactory based cache and is mainly responsible for
caching objects across sessions.

B - The second-level cache is the Session based cache.


C - Both of the above.

D - None of the above.

Q 16 - Whis of the following is true about second level cache in hibernate?

A - The second-level cache is the SessionFactory based cache.

B - The second-level cache can be configured on a per-class and per-collection basis.

C - The second-level cache is mainly responsible for caching objects across sessions.

D - All of the above.

Q 17 - Is first level caching mandatory in hibernate?

A - true

B - false

Q 18 - Is second level caching mandatory in hibernate?

A - true

B - false

Q 19 - Is query level caching mandatory in hibernate?

A - true

B - false

Q 20 - What is Query level cache in hibernate?

A - The query-level cache is cache for query resultsets that integrates closely with the second-
level cache.

B - The query-level cache is the Session based cache.

C - Both of the above.

D - None of the above.

Q 21 - Which of the following is true about query level cache in hibernate?

A - Query level cache is an optional feature.

B - Query level cache requires two additional physical cache regions that hold the cached query
results and the timestamps when a table was last updated.

C - Query level cache is only useful for queries that are run frequently with the same parameters.

D - All of the above.

Q 22 - Which of the following is a concurrency strategies in hibernate?


A - Transactional

B - Read-write

C - Nonstrict-read-write.

D - All of the above.

Q 23 - When a Transactional concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

Q 24 - When a Read-write concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

Q 25 - When a Nonstrict-read-write concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

ANSWER SHEET

Question Number Answer Key

1 A

2 A

3 A

4 A

5 A

6 C
7 D

8 A

9 A

10 B

11 A

12 D

13 A

14 D

15 A

16 D

17 A

18 B

19 B

20 A

21 D

22 D

23 B

24 B

25 C

Loading [MathJax]/jax/output/HTML-CSS/jax.js
HIBERNATE MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

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.

HIBERNATE MOCK TEST IV

Q 1 - When a Read-only concurrency strategy is to be used?

A - Use it for reference data only.

B - Use this strategy for read-mostly data where it is critical to prevent stale data in concurrent
transactions.

C - Use this strategy if data hardly ever changes and a small likelihood of stale data is not of
critical concern.

D - None of the above.

Q 2 - Which of the following is true with respect to ORM vs JDBC?

A - ORM system lets business code access objects rather than DB tables.

B - ORM system hides details of SQL queries from OO logic.

C - ORM system helps in Transaction management and automatic key generation.

D - All of the above.

Q 3 - Which of the following is true about hibernate?

A - Hibernate does not require an application server to operate.

B - Hibernate manipulates Complex associations of objects of your database.

C - Hibernate minimize database access with smart fetching strategies.

D - All of the above.

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

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

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

A - Transaction

B - SessionFactory

C - Session

D - All of the above

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

A - true

B - false

Q 8 - The SessionFactory is heavyweight object.

A - false

B - true

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

A - false

B - true

Q 10 - A Session is used to get a physical connection with a database.

A - true

B - false

Q 11 - The Session object is lightweight.

A - false
B - true

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

A - false

B - true

Q 13 - Which of the following is true about hibernate annotations?

A - Hibernate Annotations is the powerful way to provide the metadata for the Object and
Relational Table mapping.

B - 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.

C - Both of the above.

D - None of the above.

Q 14 - Which of the following is true about @Id annotation?

A - Hibernate detects that the @Id annotation is on a field.

B - Hibernate assumes that it should access properties on an object directly through fields at
runtime.

C - Both of the above.

D - None of the above.

Q 15 - Which of the following is true about @Entity annotation?

A - @Entity annotation marks a class as an entity bean.

B - Class marked with @Entity annotation must have a no-argument constructor that is visible
with at least protected scope.

C - Both of the above.

D - None of the above.

Q 16 - Which of the following is true about @Table annotation?

A - The @Table annotation allows to specify the details of the table that will be used to persist the
entity in the database.

B - The @Table annotation allows to override the name of the table, its catalogue, and its
schema, and enforce unique constraints on columns in the table.

C - Both of the above.

D - None of the above.

Q 17 - Which of the following is true about @GeneratedValue annotation?


A - @GeneratedValue annotation takes two parameters strategy and generator.

B - @GeneratedValue annotation provides the primary key generation strategy to be used.

C - Both of the above.

D - None of the above.

Q 18 - Which of the following is true about @Column annotation?

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

B - The @Column annotation is applied on a class.

C - Both of the above.

D - None of the above.

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


explicitly specified.

A - true

B - false

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

Q 21 - nullable attribute of @Column annotation permits the column to be marked


NOT NULL when the schema is generated.

A - true

B - false

Q 22 - Which of the following is true about HQL?

A - Hibernate Query Language HQL is an object-oriented query language.

B - Instead of operating on tables and columns, HQL works with persistent objects and their
properties.

C - Both of the above.

D - None of the above.

Q 23 - Which of the following is true about HQL?

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

C - Both of the above.

D - None of the above.

Q 24 - Which of the following is true about HQL?

A - Hibernate supports named parameters in its HQL queries.

B - HQL supports a range of aggregate methods, similar to SQL.

C - Both of the above.

D - None of the above.

Q 25 - Which of the following is true about INSERT CLAUSE in HQL?

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

B - HQL supports INSERT INTO clause without any restriction.

C - Both of the above.

D - None of the above.

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 C

14 C

15 C

16 C
17 C

18 A

19 A

20 B

21 A

22 C

23 C

24 C

25 A

Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js
SPRING MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

This section presents you various set of Mock Tests related to Spring 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.

SPRING MOCK TEST I

Q 1 - What is spring?

A - Spring is an open source development framework for enterprise Java.

B - Spring is a proprietary framework.

C - Spring is a development framework for .Net applications.

D - Spring is a development framework for PHP based applications.

Q 2 - Which of the following is correct assertion about spring?

A - Spring enables developers to develop enterprise-class applications using POJOs.

B - Spring is organized in a modular fashion.

C - Testing an application written with spring is simple because environment-dependent code is


moved into this framework.

D - All of above.

Q 3 - What is Dependency Injection?

A - It is a design pattern which implements Inversion of Control for software applications.

B - It is one of the spring module.

C - It is a technique to get dependencies of any project.

D - It is used to promote tight coupling in code.

Q 4 - Which of the following is correct about dependency injection?

A - It helps in decoupling application objects from each other.


B - It helps in deciding the dependencies of objects.

C - It stores objects states in database.

D - It stores object states in file system.

Q 5 - What AOP stands for?

A - Aspect Oriented Programming

B - Any Object Programming

C - Asset Oriented Programming

D - Asset Oriented Protocol

Q 6 - What is true about cross-cutting concerns?

A - The functions that span multiple points of an application are called cross cutting concerns.

B - Cross-cutting concerns are conceptually separate from the application's business logic.

C - Logging is one of the examples of cross cutting concerns.

D - All of the above.

Q 7 - Which are the modules of core container?

A - Beans, Core, Context, SpEL

B - Core, Context, ORM, Web

C - Core, Context, Aspects, Test

D - Bean, Core, Context, Test

Q 8 - Which are the modules of Data Access/ integration layer?

A - JDBC, ORM, OXM, JMS, Transactions

B - JDBC, ORM, OXM, JMS

C - JDBC, ORM, Web, Beans

D - JDBC, ORM, OXM, JMS

Q 9 - Which are the modules of Web layer?

A - WebSocket, Servlet, Web, Portlet

B - WebSocket, Servlet, Web-MVC, Web

C - HTML, JSP, WEB, Portlet

D - HTML, Servlet, WEB, Portlet

Q 10 - Which of the statement is not correct?


A - Core and beans modules provide the fundamental parts of the framework, including
Dependency Injection feature.

B - The SpEL module provides a powerful Expression Language for querying and manipulating an
object graph at runtime.

C - Aspects module provides integration with AspectJ.

D - None of the above.

Q 11 - Which of the statement is correct?

A - The JDBC module provides a JDBC-abstraction layer that removes the need to do tedious JDBC
related coding.

B - The ORM module provides integration layers for popular object-relational mapping APIs,
including JPA, JDO, Hibernate, and iBatis.

C - The Java Messaging Service JMS module contains features for producing and consuming
messages.

D - All of the above.

Q 12 - Which of the statement is correct?

A - The AOP module provides aspect-oriented programming implementation allowing you to


define method-interceptors and pointcuts to cleanly decouple code that implements functionality
that should be separated.

B - The Aspects module provides integration with AspectJ - Which is again a powerful and mature
aspect oriented programming AOP framework.

C - The Instrumentation module provides class instrumentation support and class loader
implementations to be used in certain application servers.

D - All of the above.

Q 13 - What types of Dependency injection does spring supports?

A - Constructor based, Setter based

B - Constructor based, Setter based, Getter Based

C - Setter based, Getter based, Properties based

D - Constructor based, Setter based, Properties based

Q 14 - Which are the IoC containers in Spring?

A - BeanFactory, ApplicationContext

B - BeanFactory, ApplicationContext, IocContextFactory

C - BeanFactory, BeanContext, IocContextFactory

D - BeanFactory, ApplicationContext, BeanContext

Q 15 - Which is the correct implementation class of BeanFactory?


A - XmlBeanFactory

B - ClassPathBeanFactory

C - FileSystemBeanFactory

D - AdvancedBeanFactory

Q 16 - Which are the correct implementation classes of ApplicationContext?

A - FileSystemXmlApplicationContext, ClassPathXmlApplicationContext,
WebXmlApplicationContext

B - FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext

C - AdvancedApplicationContext, FileApplicationContext

D - FileSystemApplicationContext, ClassPathApplicationContext

Q 17 - Which of the following stands true for spring beans?

A - Spring beans are managed by the Spring IoC container.

B - Spring beans are instantiated, assembled, and otherwise managed by a Spring IoC container.

C - Spring beans are simple POJOs.

D - All of the above.

Q 18 - Which is the way to provide configuration metadata to spring?

A - XML Based configuration file.

B - Annotation based configuration.

C - Java based configuration.

D - All of the above.

Q 19 - What is bean scope?

A - Bean scope forces Spring to produce a new bean instance as per the scope defined.

B - Bean scope defines the accessibility of bean in a java class.

C - Bean scope defines the accessibility of bean in a java package.

D - Bean scope defines the accessibility of bean in a web application.

Q 20 - What is singleton scope?

A - This scopes the bean definition to a single instance per Spring IoC container.

B - This scopes the bean definition to a single instance per HTTP Request.

C - This scopes the bean definition to a single instance per HTTP Session.

D - This scopes the bean definition to a single instance per HTTP Application/ Global session.
Q 21 - What is prototype scope?

A - This scopes a single bean definition to have any number of object instances.

B - This scopes the bean definition to a single instance per HTTP Request.

C - This scopes the bean definition to a single instance per HTTP Session.

D - This scopes the bean definition to a single instance per HTTP Application/ Global session.

Q 22 - What is request scope?

A - This scopes a bean definition to an HTTP request.

B - This scopes the bean definition to Spring IoC container.

C - This scopes the bean definition to HTTP Session.

D - This scopes the bean definition HTTP Application/ Global session.

Q 23 - What is session scope?

A - This scopes a bean definition to an HTTP session.

B - This scopes the bean definition to Spring IoC container.

C - This scopes the bean definition to HTTP request.

D - This scopes the bean definition to HTTP Application/ Global session.

Q 24 - What is global-session scope?

A - This scopes a bean definition to an HTTP Application/ Global session.

B - This scopes the bean definition to Spring IoC container.

C - This scopes the bean definition to HTTP request.

D - This scopes the bean definition to HTTP Session.

Q 25 - What is default scope of bean in Spring framework?

A - singleton

B - prototype

C - request

D - session

Q 26 - How can you inject Java Collection in Spring?

A - Using list, set, map or props tag.

B - Using lit, set, map or collection tag.

C - Using list, set, props or collection tag.


D - Using list, collection, map or props tag.

Q 27 - What is true about <list> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This can be used to inject a collection of name-value pairs where the name and value are
both Strings.

Q 28 - What is true about <set> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This can be used to inject a collection of name-value pairs where the name and value are
both Strings.

Q 29 - What is true about <map> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This tag is not supported.

Q 30 - What is true about <props> collection configuration elements?

A - This helps in wiring a list of values, allowing duplicates.

B - This helps in wiring a list of values but without any duplicates.

C - This can be used to inject a collection of name-value pairs where name and value can be of
any type.

D - This can be used to inject a collection of name-value pairs where the name and value are
both Strings.

Q 31 - What is bean autowiring?

A - Autowiring lets Spring resolve collaborators otherbeans for your bean by inspecting the contents
of the BeanFactory without using <constructor-arg> and <property> elements.

B - Autowiring injects values in spring beans.

C - Autowiring injects one bean into another.


D - Autowiring helps in wiring a list of values, allowing duplicates.

Q 32 - Which are the different modes of autowiring?

A - no, byName, byType, constructor, autodetect

B - no, byName, byType, constructor, autocorrect

C - byName, byContent, constructor, autodetect

D - byName, byContent, setter, autodetect

Q 33 - What is no mode of autowiring?

A - Default setting which means no autowiring and you should use explicit bean reference for
wiring.

B - Autowiring by property name.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Similar to byType, but type applies to constructor arguments.

Q 34 - What is byName mode of autowiring?

A - Default setting which means no autowiring and you should use explicit bean reference for
wiring.

B - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Similar to byType, but type applies to constructor arguments.

Q 35 - What is byType mode of autowiring?

A - Default setting which meas no autowiring and you should use explicit bean reference for
wiring.

B - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Autowiring by property type. Spring tries to match and wire a property if its type matches with
exactly one of the beans name in configuration file.

Q 36 - What is constructor mode of autowiring?

A - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

B - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.
C - Autowiring by property type. Spring tries to match and wire a property if its type matches with
exactly one of the beans name in configuration file.

D - Similar to byType, but type applies to constructor arguments. If there is not exactly one bean
of the constructor argument type in the container, a fatal error is raised.

Q 37 - What is autodetect mode of autowiring?

A - Similar to byType, but type applies to constructor arguments. If there is not exactly one bean
of the constructor argument type in the container, a fatal error is raised.

B - Autowiring by property name. Spring tries to match and wire its properties with the beans
defined by the same names in the configuration file.

C - Spring first tries to wire using autowire by constructor, if it does not work, Spring tries to
autowire by byType.

D - Autowiring by property type. Spring tries to match and wire a property if its type matches with
exactly one of the beans name in configuration file.

Q 38

Can you inject null and empty string values in Spring?

A - Yes

B - No

Q 39 - How do you turn on annotation wiring?

A - Add <annotation-context:config /> to bean configuration.

B - Add <annotation-config /> to bean configuration.

C - Add <annotation-context-config /> to bean configuration.

D - Add <context:annotation-config/> to bean configuration.

Q 40 - What does @Required annotation mean?

A - This annotation indicates that bean property must be populated by the user.

B - This annotation indicates that bean property is required while saving the bean data to
database.

C - This annotation simply indicates that the affected bean property must be populated at
configuration time, through an explicit property value in a bean definition or through autowiring.

D - This annotation indicates that bean property is required while serializing the bean.

Q 41 - What is true about @Autowired annotation?

A - The @Autowired annotation can be used to autowire bean on the setter method.

B - This annotation provides more fine-grained control over where and how autowiring should be
accomplished.

C - The @Autowired annotation can be used to autowire bean on the methods with arbitrary
names and/or multiple arguments.

D - All of above.

Q 42 - What is ContextRefreshedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP Response is returned.

D - This event is published when the ApplicationContext is either initialized or refreshed.

Q 43 - What is ContextStartedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the ApplicationContext is started using the start method on the
ConfigurableApplicationContext interface.

D - This event is published when the HTTP Response is returned.

Q 44 - What is ContextStoppedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the ApplicationContext is stopped using the stop method on the
ConfigurableApplicationContext interface.

C - This event is published when the HTTP Request is received.

D - This event is published when the HTTP Response is returned.

Q 45 - What is ContextClosedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP Response is returned.

D - This event is published when the ApplicationContext is closed using the close method on the
ConfigurableApplicationContext interface.

Q 46 - What is RequestHandledEvent:event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP session is initialized or refreshed.

D - This event is published when the HTTP Request is serviced.


Q 47 - What is aspect?

A - Aspect is a way to do the dependency injection.

B - A module which has a set of APIs providing cross-cutting requirements.

C - Aspect is used to log information of application.

D - Aspect represents properties of spring based application.

Q 48 - What is Join point?

A - This represents a point in your application which joins two objects.

B - This represents a point in your object where you join values.

C - This represents a point in your object where you join injected values.

D - This represents a point in your application where you can plug-in AOP aspect.

Q 49 - What is Advice?

A - This is the way to instruct object to behave in certain manner.

B - This is used to inject values in objects.

C - This is the actual action to be taken either before or after the method execution.

D - This is not invoked during program execution by Spring AOP framework.

Q 50 - What is Pointcut?

A - This represents a point in your application where you can plug-in AOP aspect.

B - This is a set of one or more joinpoints where an advice should be executed.

C - This is used to inject values in objects.

D - This is invoked during program execution by Spring AOP framework.

ANSWER SHEET

Question Number Answer Key

1 A

2 D

3 A

4 A

5 A

6 A

7 A

8 A
9 A

10 D

11 D

12 D

13 A

14 A

15 A

16 A

17 D

18 D

19 A

20 A

21 A

22 A

23 A

24 A

25 A

26 A

27 A

28 B

29 C

30 D

31 A

32 A

33 A

34 B

35 D

36 D

37 C

38 A

39 D

40 C

41 B

42 D

43 C
44 B

45 D

46 C

47 B

48 D

49 C

50 B

Loading [MathJax]/jax/output/HTML-CSS/jax.js
SPRING MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

This section presents you various set of Mock Tests related to Spring 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.

SPRING MOCK TEST III

Q 1 - What is Introduction?

A - An introduction represents a point in your application where you can plug-in AOP aspect.

B - This is used to inject values in objects.

C - This is not invoked during program execution by Spring AOP framework.

D - An introduction allows you to add new methods or attributes to existing classes.

Q 2 - What is Target object?

A - A represents a object in your application where you can plug-in AOP aspect.

B - The object being advised by one or more aspects, this object will always be a proxy object,
also referred to as the advised object.

C - This is used to inject values in objects.

D - This is not invoked during program execution by Spring AOP framework.

Q 3 - What is Weaving?

A - Weaving is the process of injecting values in objects to create an advised object.

B - Weaving is the process of linking aspects with other application types or objects to create an
advised object.

C - This is used to inject values in objects.

D - Weaving is used to check object dependencies.

Q 4 - What are the different points where weaving can be applied?

A - Compile time, load time


B - Compile time, run time

C - Run time

D - Compile time, load Time, Run time

Q 5 - What are the types of advice?

A - then, after, after-returning, after-throwing, around

B - When, after, after-returning, around

C - Where, after, after-returning, after-throwing, around

D - Before, after, after-returning, after-throwing, around

Q 6 - How before advice works?

A - Run advice before a class loads.

B - Run advice before a method execution.

C - Run advice before http response is to be returned.

D - Run advice before http request is to be processed.

Q 7 - How after-returning advice works?

A - Run advice after a class loads only if class loads successfully.

B - Run advice after a method execution only if method completes successfully.

C - Run advice after http response is returned only if http response is success.

D - Run advice after http request is processed with no exception.

Q 8 - How after-throwing advice works?

A - Run advice after a method execution only if method exits by throwing an exception.

B - Run advice after a class loads only if class throws exception during load time.

C - Run advice after http response is returned with error status.

D - Run advice after http request is processed and an exception occurred.

Q 9 - How around advice works?

A - Run advice before and after the advised method is invoked.

B - Run advice before and after a class is loaded.

C - Run advice before and after http response is returned.

D - Run advice before and after http request is processed.


Q 10 - Which of the following aspect implementation spring supports?

A - XML Schema based aspect implementation

B - @AspectJ based aspect implementation

C - Both of above.

D - None of above.

Q 11 - What are the types of the transaction management Spring supports?

A - Programmatic transaction management

B - Declarative transaction management

C - Both of above.

D - None of above.

Q 12 - What is Spring MVC framework?

A - Spring MVC framework is Model-Value-Class architecture and used to bind model data with
values.

B - The Spring web MVC framework provides model-view-controller architecture and ready
components that can be used to develop flexible and loosely coupled web applications.

C - Spring MVC framework is used for Transaction management for Web Applications.

D - Spring MVC framework is used for AOP for Web Applications.

Q 13 - What is @Controller annotation?

A - The @Controller annotation indicates that a particular class serves the role of a controller.

B - The @Controller annotation indicates how to control the transaction management.

C - The @Controller annotation indicates how to control the dependency injection.

D - The @Controller annotation indicates how to control the aspect programming.

Q 14 - What are the ways to access Hibernate by using Spring?

A - Inversion of Control with a Hibernate Template and Callback.

B - Extending HibernateDAOSupport and Applying an AOP Interceptor node.

C - Both of above.

D - None of above.

Q 15 - Which ORM Spring supports ?

A - Hibernate

B - iBatis

C - JPA
D - All of above.

E - None of above.

Q 16 - Which of the following database is not supported using jdbcTemplate?

A - MySql

B - PostgresSql

C - NoSql

D - Oracle

Q 17 - How to get object of a service in spring framework?

A - Using new keyword

B - Using dependency injection

Q 18 - Which of the following is part of Data Access layer in Spring framework?

A - Beans

B - Aspects

C - JMS

D - Context

Q 19 - How to use ref keyword in beans.

xml?

A - Using setter method only.

B - Using constructor argument only.

C - Using setter method and constructor argument both.

D - None of the above.

Q 20 - Core container has AOP as one of its module.

A - True

B - False

Q 21 - SpEL is part of core container.

A - False

B - True
Q 22 - Which class acts as IoC Container?

A - ServletContext

B - DispatcherServlet

C - ApplicationContext

D - None of the above

Q 23 - What stands true for spring framework?

A - Spring framework is a light weight framework.

B - Spring framework is a heavy weight framework.

Q 24 - Expression Language/ SpEL was introduced in which version of spring


framework.

A - 1.0

B - 2.0

C - 3.0

D - 4.0

Q 25 - Can we integrate Struts with Spring.

A - Yes

B - No

Q 26 - By default a bean is lazily loaded.

A - True

B - False

Q 27 - By default a bean is eagerly loaded.

A - False

B - True

Q 28 - If a bean is scoped to HTTP request, scope is

A - session

B - global-session

C - prototype

D - request
Q 29 - If a bean is created once per Ioc Container, scope is

A - singleton

B - global-session

C - prototype

D - request

Q 30 - Thread scoped bean is introduced in which version of spring framework.

A - 1.0

B - 2.0

C - 3.0

D - 4.0

Q 31 - If a bean can be created any number of times, scope is

A - session

B - global-session

C - prototype

D - request

Q 32 - What is the scope of stateless bean?

A - global-session

B - singleton

C - prototype

D - request

Q 33 - What is the scope of stateful bean?

A - session

B - global-session

C - prototype

D - request

Q 34 - If a bean is scoped to HTTP session, scope is

A - global-session

B - session

C - prototype

D - request
Q 35 - How to handle shut down of IoC container?

A - Using shutdownHook

B - Using shutdownHandler

C - Using registerHook

D - Using registerShutdownHook

Q 36 - How bean life cycle can be controlled?

A - Using init only

B - Using InitializingBean class only

C - Using DisposableBean class only

D - Using All of above

Q 37 - What is the scope of bean in portlet context?

A - session

B - global-session

C - prototype

D - request

Q 38 - How after advice works?

A - Run advice after a method execution regardless of its outcome.

B - Run advice after a class loads.

C - Run advice after http response is returned.

D - Run advice after http request is processed.

Q 39 - Which class is used to map a database row to a java object in spring?

A - ResultSet

B - RowMapper

C - RowSetMapper

D - ResultSetMapper

Q 40

A bean must have id attribute in beans configuration file.

A - True
B - False

Q 41 - Which of the following class can be used to execute Sql queries in spring?

B - JDBCHelper

A - JdbcTemplate

C - DBHelper

D - DBTemplate

Q 42 - Which of the following class can be used to call Stored Procedures in spring?

A - SPHelper

B - JdbcTemplateCall

C - JdbcTemplate

D - SimpleJdbcCall

Q 43 - What is a DispatcherServlet?

A - DispatcherServlet is used for transaction management.

B - DispatcherServlet is used for AOP.

C - DispatcherServlet handles all the HTTP requests and responses.

D - DispatcherServlet is used for Dependency injection.

Q 44 - What is ACID in transactional management?

A - Accurate, Controlled, Isolation, Durability

B - Atomicity, Consistency, Independent, Done

C - Atomicity, Consistency, Isolation, Durability

D - Accurate, Controlled, Independent, Done

Q 45 - Where do you define DispatcherServlet?

A - In Beans configuration file.

B - Web.xml file

C - Meta-inf/dispatcher.xml

D - Web-inf/ dispatcher.xml

Q 46 - What is true about BeanPostProcessor?

A - It is a concrete class.

B - It is an interface.
C - It is an abstract class.

D - None of the above.

Q 47 - What BeanPostProcessor does?

A - It processes beans once a bean is initialized.

B - It defines callback methods that you can implement to provide your own instantiation logic,
dependency-resolution logic etc.

C - It processes beans once a bean is loaded.

D - It processes beans once a bean exits.

Q 48 - Can be bean be configured to have an inner bean?

A - True

B - False

Q 49 - Can we inject value and ref both together in a bean?

A - True

B - False

Q 50 - Following class can be extended to create custom event in spring.

A - SpringEvent

B - Event

C - ApplicationEvent

D - None of above

ANSWER SHEET

Question Number Answer Key

1 D

2 B

3 B

4 D

5 D

6 B

7 B

8 A
9 A

10 C

11 C

12 B

13 A

14 C

15 D

16 C

17 B

18 C

19 C

20 B

21 B

22 C

23 A

24 C

25 A

26 B

27 B

28 D

29 A

30 C

31 C

32 B

33 C

34 B

35 D

36 D

37 B

38 A

39 B

40 B

41 A

42 D

43 C
44 C

45 B

46 B

47 B

48 A

49 A

50 C

Loading [MathJax]/jax/output/HTML-CSS/jax.js
1.The central artifact in spring javaConfig is the @Configuration-annotated class.State true or False.

ans:true

2.What are the modules of spring web flow?

a.Spring-faces -----------

b.Spring-bundling

c.Spring-container ------

d.Spring-webflow -----

3.XML mapping file offers which of the following?

4.In spring MVC each tag provides support to the set of attributes of its corresponding HTML tag
counterpart making the tags familiar & intuitive to use

State true or False. true

5.Which of the following are mandatory rules to create validation for a normal employee table?

a.The "empNum" cant be empty

b."Name" cant be empty

c.The "empNum" cant be less than 1

d.All of the option ---------

6.Which of the following allows as to add a new method or attributes to existing classes?

a.Introduction -----

b.Proxy

c.Weaving

d.Auto call

7.Given the following Spring configuration file, what is the correct answer:
<bean class="com.spring.service.MyServiceImpl">

<property name="repository" ref="jpaDao"/>

</bean>

<bean class="com.spring.repository.JpaDao"/>

a. The first declared bean MyServiceImpl is missing an id must be named myService

b. The second declared bean JpaDao is missing an id must be named jpaDao ------------

c. Answers 1 and 2 are both rights

d. Answers 1 and 2 are both wrong

8.Which of the following are the best practices for writing spring XML configuration?

a.Rarely use classpath

b.Mentioning version numbers in schema reference

c.Using consistent naming conventions--------

d.Reuse bean definitions as much as possible------------

best practices:

1) Add a header comment to each configuration file

2) Use consistent naming conventions

3) No version numbers in schema references

4) Prefer setter injection over constructor injection

5) Prefer type over index for constructor argument matching

6) Use shortcut forms over expanded forms

7) Reuse bean definitions as much as possible

8) Always use ids as bean identifiers

9) Try to avoid autowiring

10) Always use classpath prefix


11) Always externalize properties

12) Use dependency-check at the development phase

13) Do not abuse/overuse dependency injection

9.Spring MVC provides better way to seperate which of the following?

a.Presentation

b.Tools

c.Data Access

d.Bussiness Logic -----

10.We can use index and type attribute together

State true or False. -true

11.which of the following is Hibernate?

a.Lightweight

b.Open Source

c.ORM

d.All of the listed-----------

12.Which of the following options about Auto Wiring in spring are correct?

1.Auto-wiring in spring framework can be performed by configuring xml and auto-wiring with
annotation @Autowired. ----

2.Auto-wiring beans with xml configuration:I spring framework, you can wire automatically with auto-
wiring feature.

3.To enable auto-wiring just define the "autowire" attribute in <bean> tag. -------

13.Which of the following parses in xml based on expression and its used extensively in conjuction with
XLST?

a.Xpath parser ----------


b.SAX parser

c.STAX Parser

d.JDOM Parser

14.Length attribute of @column annotation permits the size of the column used to map a value
particularly for a string value.

State true or False. -----true

15.When we work with an object oriented system there's a mismatch between the object modal and the
relational database. State true or False.

-----true

16.Which of the following is true about JDBC?

a.JDBC APIs enables java programs to execute SQL statements and interact with any SQL Complaint
database

b.JDBC stands for Java Database Connectivity

c.it provides set of java API for accessing the relational databases from java program

d.All the listed option -----------

17.- What is session scope?

A - This scopes a bean definition to an HTTP session. -------------

B - This scopes the bean definition to Spring IoC container.

C - This scopes the bean definition to HTTP request.

D - This scopes the bean definition to HTTP Application/ Global session

18.Which of the listed statement are correct for spring Bean scope:Prototype?

1.Spring container creates new instance of bean for each and every request for that bean-------------

2.Prototype scoped bean is served by creating new instance of bean for each and every bean
dependency----------

3.After instatiating bean and submitting it to client spring container will maitain the record(not
maintain)
4.Prototype scope is spring standard scope and can be used in standalone as well as web application of
spring.------

19.ServletWrappingController-Wraps an existing servlet which is managed completely by the spring


environment.State true or False.

---------true

20.Hibernate session is the main runtime interface between a java application and Hibernate.State true
or False.

-----true

23.Which of the following are correct in sql queries in hibernate.

1.sql queries may contain named and positional parameters, just like hibernate queries----------

2.You may express aquery in sql usig createSQLQuery()-------

3Hibernate take care of the mapping from result sets to objects--------

4.You may call session.connection() and use JDBC Connection at any time

24.Which is the query language that embodies a very powerful and flexible mechanism to query, store,
update and retrive

objects from a database?

a.PLSQL

b.RDBMS

c.SQL

d.HQL----------------

25.What is spring MVC framework?

a.spring MVC framework is used for Transaction management for web application-----

b.spring MVC framework is Model-value-class architecture and used to bind model data

c.spring MVC framework is used for AOP for web application -------

d.spring web MVC framework provides model-view-controller architecture and ready components that
can be used to develop flexible and loosely coupled web applications

--------------
26.Which of the listed options are True for bean configuration inheritance?

1.In spring the inheritance is supported in bean to share common values properties or configurations.---
---

2.A child bean or inherited bean can inherit its parent bean configurations, properties & some
attributes --

3.the parent bean allow to override the inherited values.-------

27.XsltViewResolver-supports XsltView by resolving the view name of which of the following options?

a.View name of the URL of the report file

b.URL of the XSLT

c.VelocityView and its subclasses

d.All of the option

28.[xml]

<id name="depId" type="string">

<colum name="columnId" length="30"/>

<generator/>

</id>

[xml]

The above is an example of creating which key?

a.Primary key -------------------

b.Secondary key

c.Unique key

d.

29.When you need to upload a large number of records into your database using Hibernate, you can use
batch processing.State true or False.

---true

30.Different types of run advice "before" and "after" the advised method is invoked.Which of the
following is the correct option with respect to advice?
a.After returning

b.None

c.After throwing

d.around ---

31.Implementation of viewResolver accets a configuration file written in XML with the same DTD as
spring XML bean factories.State true or False.

---------true

32.Choose the odd one out respect to annotations from the following

a.@requestmapping

b.@controller

c.@responsevalid------------

d.@Pathvalid-------

33.For a fast Development, the depenndency injection feature of spring Framework &

support to various Frameworks makes the easy development of javaEE application.state true or False.---
--true

34.Testing an application written with Spring is complex because environment-dependent

code is moved into this framework.state true or False.--false (simple)

35.The application is designed around an object model.Sql code is generated at build time

& the assosiations between obj are supported by the persistence mechanism, and queries are

specified using an obj-oriented expression language.This is best suited for medium-sized applications

with some complex transactions.Used when mapping exceeds 25 differentdatabase products at a time.

which of the following is this called as?

a.Object mapping

b.Application object mapping

c.Medium object mapping-------------------


d.Expression object mapping

36.Which of the following is not the steps for creating web MVC?

a.Provide exit controller in the web

b.Create a controller class

c.start server 7 deploy the project

d.Define the bean in the xml file

37.Maven is a project management &comprehension tool.

state true or False.

Ans:True

38.Which of the following elements is used to represent one-to-one relationship in hibernate?

a.<many-to-one>

b.<ManyTOOne>

c.<many-one>

d.none

Ans:<many-to-one>

39.In hibernate implement cache for a query ,if the result sets can integrate closely,which level

of the cache can be implemented?

a.first level cache

b.second level cache-------

c.third level cache

d.Fourth level cache

40.Spring MVC provides predefined templates for JDBC, Hibernate and JPA.state true or False.------true

Ans:True
41.In Spring MVC which of the following is the front controller class that initializes the context

based on the spring beans configuration?

a.org.springframework.web.servlet.DispatcherServlet-----------------------------------

b.org.springframework.web.context.DispatcherServlet

c.org.springframework.web.servlet

d.org.springframework.web.context.ApplicationContext

42.Which of the following is NOT the type of mapping?

a.Instance mapping-------------

b.Component mapping

c.Association mapping

d.Class mapping

43.Which of the following are modules of Web layer?

A - WebSocket, Servlet, Web, Portlet--------------

B - WebSocket, Servlet, Web-MVC, Web

C - HTML, JSP, WEB, Portlet

D - HTML, Servlet, WEB, Portlet

44.Which of the following statements are correct?

a.Bean Factory and ApplicationContext are basic container only

b.Bean Factory is basic container and ApplicationContext is advanced container------------------------

c.Bean Factory and ApplicationContext are advanced container

d.Bean Factory is advanced container and ApplicationContext is basic container

45.In spring bean configuration bean atribute called 'scope' defines what kind of object

has to be created and returned. What returns a new bean instance each time when required?

a.Prototype----

b.Session
c.Singleton

d.Global session

46.To validate the form fields you need to have a seperate UserValidator class

that implements the validator interface,override the validate() method perform all the validations.state
true or False.

------true

47.The application context implements which of the following interface that is used to obtain localized

messages,with the actual implementation being pluggable?

1.messageSource -------------------

2.RequestMapping

3.both

4.neither

48.Which of the following is an available aggregate function in HQL?

a.Aggregate(property name)

b.Count(property name or *)-------------

c.max(property name)-------------------

d.avg(property name)-------------------

49.What statement is not correct in live environment? Select a unique answer.

1. Constuctor and properties autowiring in the same bean are not compatible

2. A bean should have a default or a no-args constructor

3. The <constructor-arg> tag could take type, name and index to reduce ambiguity

4. None of the above

5. All of the above-------------------

50.- What is ContextClosedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.
B - This event is published when the HTTP Request is received.

C - This event is published when the HTTP Response is returned.

D - This event is published when the ApplicationContext is closed using the close method on the

ConfigurableApplicationContext interface. --------

51.Which of the following explains about addclass function in the listed options?

a.this function translate a java class name into file name

b.this translated file name is then loaded as an input stream from the java class loader

c.this addclass function is important if you want efficient usage of classes in your code----------

52.Spring MVC provides a JSP tag library(Spring form) for making it easier to bind form elements to
model data.state true or False.

Ans:True

53.Which of the following is correct assertion about spring?

a.Spring enables developers to develop enterprise-class applications using POJOs.

b.Spring is organized in a modular fashion.

c.Testing an application written with spring is simple because environment-dependent code is moved
into this framework.

d.All of above.------------------------

54.Which of the following statement is INCORRECT by extending VIewResolver and


ChainingViewResolver?

a. programmers can have custom view resolvers

b. There are lot of view resolvers available in Spring framework

c. Spring MVC view resolvers help the Dispatcher Servlet in identifying the views which has to be
rendered in response for a request.

d.none--------------------------
55.What are the benefits of Spring Framework's transaction management?

a.It Provides a consistent programming model across different transaction APIs such as JTA, JDBC,
Hibernate, JPA, and JDO.

b.It Supports declarative transaction management.

c.It Provides a simpler API for programmatic transaction management than a number of complex
transaction APIs such as JTA.

d.All the listed------------------

56.Given the following configuration class, what are correct affirmations? Select one or more answers.

public class ApplicationConfig {

private DataSource dataSource;

@Autowired

public ApplicationConfig(DataSource dataSource) {

this.dataSource = dataSource;

@Bean(name="clientRepository")

ClientRepository jpaClientRepository() {

return new JpaClientRepository();

1. @Configuration annotation is missing---------

2. Default or no-arg constructor is missing------------

3. @Bean name is ambiguous

4. @Bean scope is prototype

57.What is true about <list> collection configuration elements?


A.This helps in wiring a list of values, allowing duplicates.----------<list>

B.This helps in wiring a list of values but without any duplicates.-----<set>

C.This can be used to inject a collection of name-value pairs where name and value can be of

any type.--------<map>

D.This can be used to inject a collection of name-value pairs where the name and value are

both Strings.----------<props>

Ans:This helps in wiring a list of values, allowing duplicates.

58.Which are the correct implementation classes of ApplicationContext?

A.FileSystemXmlApplicationContext,ClassPathXmlApplicationContext,

WebXmlApplicationContext-------------

B.FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext

C.AdvancedApplicationContext, FileApplicationContext

D.FileSystemApplicationContext, ClassPathApplicationContext

59.It is difficult to inject the dependency by constructor. state true or False.---true

60.The Model-View-Controller(MVC) is an architectural pattern that does not separate an application


into three main logical compponents: the model,the view and the controller.

state true or False.-------false

1)Given the following configuration class, what are correct affirmations? Select one or more answers.

public class ApplicationConfig {

private DataSource dataSource;


@Autowired

public ApplicationConfig(DataSource dataSource) {

this.dataSource = dataSource;

@Bean(name="clientRepository")

ClientRepository jpaClientRepository() {

return new JpaClientRepository();

1. @Configuration annotation is missing----------ANS

2. Default or no-arg constructor is missing-------ANS

3. @Bean name is ambiguous

4. @Bean scope is prototype

---------------------------------------------------------------------------------------------------------------

2)<id name="deptId" type="string">

<column name="columnid" length="30"/>

<generatoers/>

<id/>

[/xml]

The above is an example of creatinf which key?

Select One:

a.DB key

b.Unique key

c.Secondary key

d.Primary key--------ANS

--------------------------------------------------------------------------------------------------------------------
3)ApplicationContext implements which of the following interface that is used to obtain localized
messages, with the actual implementation being pluggable

I. MessageSource

II. RequestMapping

Select One:

a. only I--------------ANS

b.only II

c. Neither I or II

d. Both I and II

--------------------------------------------------------------------------------------------------------------------

4).Which of the following is a many to one relationship

a) many-to-one

b) <many-to-one>---------ANS

c) None of the list

d) <Manyone>

-------------------------------------------------------------------------------------------------------------

5)What of the following is not correct in live environment?

select one

a. Constuctor and properties autowiring in the same bean are not compatible

b. A bean should have a default or a no-args constructor

c. The <constructor-arg> tag could take type, name and index to reduce ambiguity

d. All of the above-----------ANS


--------------------------------------------------------------------------------------------------------------------------

6)Which of the following is not available in HQL

select one

a)Select

b)Where

c)Sub---------------Ans

d)Having

--------------------------------------------------------------------------------------------------

7)maven is a project management and comprehension tool

select one

True----------Ans

False

-----------------------------------------------------------------------------------------

8)How many layers are there in Hibernate architechture

select one

a)3

b)4------------Ans

c)5

d)2

------------------------------------------------------------------------

9)Beans,Core, Context,spEL are the components in Core container

select one

True----------Ans

False

-------------------------------------------------------------------------------------------------------
10) PROPAGATION_REQUIRES_NEW

Ans: Creates a new transaction, suspending the current transaction if one exists.

----------------------------------------------------------------------------------------------------------

11)Element which can be used to inject a collection of name-value pairs where the name and the value
can be of any type.

select one

a)<list>

b)<set>

c)<map>---------------ANS

d)<props>

-----------------------------------------------------------------------------------------------------------------

12)Element which can be used to inject a collection of name-value pairs where the name and the value
are both Strings type.

select one

a)<list>

b)<set>

c)<map>

d)<props>---------------ANS

-----------------------------------------------------------------------------------------

13)which type of annotation applies to bean property setter methods

select one

a)@Requires
b)@Resource

c)@Required----------------ANS

d)@Requiring

----------------------------------------------------------------------------------------------------------------------

14)ORM stands for Object-Relational Mapping (ORM) is a programming technique for converting data
between relational databases.

select one

True----------Ans

False

-------------------------------------------------------------------------------------------------------------

15)Which tool helps to generate the mapping document Though many Hibernate users choose to write
the XML by hand

select one

a)oldgen

b)younggen

c)Middlegen----------------ANS

d) Mediumgen

-------------------------------------------------------------------------------------------------------------

16)Java based configuration option disables you to write most of your Spring configuration without XML
but with the help of few Java-based annotations

select one

True

False----------Ans

----------------------------------------------------------------------------------------------------------------------------

17) What types of views supported by spring MVC for different presentation technologies

select one or more


a)JSP

b)HTML

c)velocity templates

d)

Ans: select all

---------------------------------------------------------------------------------------------------------------------------------

18)Spring is a heavy weight framework

select one

True

False----------Ans

-------------------------------------------------------------------------------------------------------------------------

19)A very powerful and high performance qurerying language used to Query,retrive,store data in DB is

select one

a)PLSQL

b)HQL-------ANS

c)SQL

d)RDBMS

----------------------------------------------------------------------------------------

20)which of the following options about Auto wiring in spring are correct?

I. The Auto wiring in spring framework can be performed by configuring in xml and spring Auto-Wiring
with Annotation @Autowired

II. Auto-wiring beans with xml configuration: In Spring framework, you can wire beans automatically
with auto wiring feature

III. To enable auto-wiring just define the "autowire" attribute in <bean> tag.
Select One:

a.I, II, and III--------ANS

b.I and III

c.I and II

d.II and III

----------------------------------------------------------------------------------------------------------------------------------

1) In Spring AOP, the process of linking aspect with other application types or objects to create an advice
object is called ________________.

Weaving(ans)

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

2) <list> tag is used to wire a list of values, allowing duplicates.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

3) BeanFactory, ApplicationContext classes acts as IoC containers in Spring.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
4) Can you inject null and empty string values in Spring? ans: yes

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

5) AOP stands for Aspect Oriented Programming.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

6) SpEL is NOT part of core container. ANS: false (it is part of core container)

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

7)Following class can be extended to create custom event in spring. ans: ApplicationEvent

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

8)Which is the way to provide configuration metadata to spring?

A - XML Based configuration file.

B - Annotation based configuration.

C - Java based configuration.

d - all-----------------ANS
------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

9)Which are the modules of Web layer? ans:WebSocket, Servlet, portlet,web

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

10) how many intances can be created fora global session : one

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

11)what display the data with help of model? Ans: View

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

12) read the below statements and ans according to questions

I.Spring enables developers to develop enterprise-class applications using POJOs.

II.Spring is organized in a modular fashion.

III.Testing an application written with Spring is simple

IV. All of the list-----------ANS


------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

13) How after advice works?

A - Run advice after a method execution regardless of its outcome.-----ANS

B - Run advice after a class loads.

C - Run advice after http response is returned.

D - Run advice after http request is processed.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

14)which can be used to inject a collection of name-value pairs where name and value can be of any
type. ANS--------MAP

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

15)What is ContextStartedEvent event?

A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the HTTP Request is received.


C - This event is published when the ApplicationContext is started using the start() method on the
ConfigurableApplicationContext interface.--ANS

D - This event is published when the HTTP Response is returned.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

16)which of the following not availble in HQL?

select

where

having

sub-----ans

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

17)which is a aggregate function in HQL(multiple choice)? ANS-sum, avg and count (dont select
aggregate)

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

18)Which of the following database is not supported by Hibernate?

A - DB2/NT

B - MySQL

C - FoundationDB----ANS
D - PostgreSQL

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

19)Which of the following is true about Hibernate?

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

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

C - Both of the above.

D - None of the above.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

20)What is the difference between save() and persist() methods of session object?

A - There is no difference.

B - save saves the object and returns status whereas persist stores status in different variable.

C - save saves the object and returns the id of the instance whereas persist do not return anything after
saving the instance.------ANS

D - None of the above.


------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

21)what is required to write a basic spring program? ANS----jdk,ide,maven,all the above

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

22)

BeanFactory, ApplicationContext classes acts as IoC containers in Spring.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

23)

JDBC, ORM, OXM, JMS, Transactions are the modules of Data Access/ Integration layer.------TRUE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

24)ContextStartedEvent event is published when the ApplicationContext is started using the start()
method on the ConfigurableApplicationContext interface.-----TRUE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

25)Spring framework is a light weight framework.------TRUE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
26)singleton is the default scope of any spring bean.-----TRUE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

27)

Analyze the below code snippet:

<bean class="com.spring.service.MyServiceImpl">

<property name="repository" ref="jpaDao"/>

</bean>

<bean class="com.spring.repository.JpaDao"/>

Which of the following statements is valid?

I. The "id" attribute must be declared for the bean "MyServiceImpl" because it is mandatory attribute.

II. In the second bean of type "com.spring.repository.JpaDao" the “id" attribute must be specified with
name "jpaDao".

Select One

a Both I and II are correct

b II only-------------------------ANS

c I only

d Both I and II are incorrect

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

28)Which of the following parses in XML based on expression and its used extensively in conjugation
with xstl ?
Select One:

a)JDOM parser

b)SAX parser

c) STAX parser

d) Xpath parser0------ANS

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

29) what is true about BeanFactory, ApplicationContext?

ANS-BeanFactory is basic and ApplicationContext is advanced

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

30)What are the common implementations of the Application Context ?

ANS-
FileSystemXmlApplicationContext,ClasspathXmlApplicationContext,WebxmlApplicationContext(answers
are confusing- xml should be common in those three)

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

31) org.springframework.web.servlet.DispatcherServlet is the congfiguration in xml file for


dispatcherServlet.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
32) The central artefact in spring javConfig is the @Configuratuion annotated class?

State True or False

a). TRUE-------------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

33) maven is a project management and comprehension tool-----True

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

34)session----This scopes a bean definition to an HTTP session only.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

35) What of the following is not correct in live environment?

select one

a. Constuctor and properties autowiring in the same bean are not compatible

b. A bean should have a default or a no-args constructor

c. The <constructor-arg> tag could take type, name and index to reduce ambiguity

d. All of the above-----ans

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
36) Given the following configuration class, what are correct affirmations? Select one or more answers.

public class ApplicationConfig {

private DataSource dataSource;

@Autowired

public ApplicationConfig(DataSource dataSource) {

this.dataSource = dataSource;

@Bean(name="clientRepository")

ClientRepository jpaClientRepository() {

return new JpaClientRepository();

1. @Configuration annotation is missing----------ANS

2. Default or no-arg constructor is missing-------ANS

3. @Bean name is ambiguous

4. @Bean scope is prototype

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

37) Question on servlet wrapping ---true

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

38)[xml]

<id name="deptId" type="string">

<column name="columnid" length="30"/>

<generatoers/>
<id/>

[/xml]

The above is an example of creatinf which key?

Select One:

a.DB key

b.Unique key

c.Secondary key

d.Primary key--------ANS

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

39)validations for normal employee class

I.Name cant be empty

I.Id cant be empty

III.Id cant be less than 1

iV.all the above------------------ANS

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

40)Not a type of mapping

I. instance mapping---ans

II. association mapping

III. Class mapping


IV.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

41)ContextClosedEvent--------is published when the ApplicationContext is closed using the close()


method on the ConfigurableApplicationContext interface

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

42)Around advice------Run advice before and after the advised method is invoked.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

43)HQL- easily stores, update and retrieve from the database

State True or False

a). TRUE-------------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

44)Hibernate is lightweight,opensource and ORM (Multiple choice)

ANS-------all the above

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

45)Hibernate session is the main runtime interface between java applications and hibernate.
State True or False

a). TRUE-------------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

46)When we work with an object oriented system, there is mismatch between the object model and the
relational database.

State True or False

a). TRUE-------------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

47)spring mvc is a model-view-controller

State True or False

a). TRUE-------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

48)form fields are validated using user defined validations class by implementing validation interface

State True or False


a). TRUE------TRUE

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

49) spring does not seperate three modules like presentation layer,bussiness layer and data access layer

State True or False

a). TRUE

b). FALSE-------ANS

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

50) pick odd one out in the following annotations

I.@PathValid ----- ans

II.@responsevalid---ans

III.@Controller

IV.@requestmapping

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

51)lenth returns number of rows in a column for only string type

State True or False

a). TRUE---ans

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
52)which level cache implements a cache for query resultsets

a.Third level cache---ans

b.Second level cache

c.First level cache

d. Fourth level cache

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

53)read about prototype and singleton scopes.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

54)form tags are available in springs is more compatible wth html tags for better development

State True or False

a). TRUE-----------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

55) Which of the following are CORRECT in SQL queries in Hibernate.

I. SQL queries may contain named and positioned parameters, just like Hibernate queries

II. You may express a query in SQL, using createSQLQuery()

III. Hibernate take care of the mapping from result sets to objects
IV. You may call session.connection() and use the JDBC Connection at any time.

select one

a. I, II, and III---ans

b. I, II, and IV

c. I, III, and IV

d. I, II, III, and IV

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

56)what are the modules in the spring-webflow(

bundling not an ans

spring-webflow

spring-

spring-

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

57)what is the function of clean maven lifecycle command

ANS-cleans artefacts in the earlier build

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

58)which of the following is not the best pracice?


I.Exit controller has to define in web.xml

II.bean definition

III.open the server and deploy the project----ans|not sure

IV.@controller usage

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

59.Constructor injection is didfficult to inject

State True or False

a). TRUE--ans

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

60.index and type can be used in the constrictor-arg at the same time?

State True or False

a). TRUE---ans

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

61.Which of the following is a one to one relationship

a) <many-to-many>

b) <many-to-one>-----ans in tutorial point

c) None of the list


d) <one-to-many>

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

62) the same XSD of BeanFactory can be used for View resolver interface?

State True or False

a). TRUE---------------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

63) Which of the following is correct assertion about spring?

A - Spring enables developers to develop enterprise-class applications using POJOs.

B - Spring is organized in a modular fashion.

C - Testing an application written with spring is simple because environment-dependent code is moved
into this framework.

D - All of above.---------ANS

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

64)

What is ContextStoppedEvent event?


A - This event is published when the Servlet Context is either initialized or refreshed.

B - This event is published when the ApplicationContext is stopped using the stop() method on the
ConfigurableApplicationContext interface.-------ANS

C - This event is published when the HTTP Request is received.

D - This event is published when the HTTP Response is returned.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

65)XsltViewResolver-supports XsltView by resolving the view name of which of the following options

a) all of the listed options

b)VelocityView and its subclasses

c)URl of xslt-------------------------------ANS

d)view name of the URL of the report file.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

66) Spring MVC provides predefined templates for JDBC, Hibernate and JPA.

State True or False

a). TRUE-------------ANS

b). FALSE
------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

67) ApplicationContext implements which of the following interface that is used to obtain localized
messages, with the actual implementation being pluggable

I. MessageSource

II. RequestMapping

Select One:

a. only I--------------ANS

b.only II

c. Neither I or II

d. Both I and II

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

68) Which of the following are the best practices for writing spring XML Configurations?

select one or more

a.Using consistent naming conventions-------ANS

b. Rarely use classpath

c.Mentioning version numbers in schema references

d.reuse bean definitions as much as possible--------ANS

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
69) To validate the form fields you need to have a seperate UserValidator class that implements the
validator interface, Override the validate() method perform all the validations.

State True or False

a). TRUE-------------ANS

b). FALSE

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

70) which of the listed options are TRUE for Bean configuration inheritance?

I. In spring, Inheritance is supported in bean configuration to share common values, properties or


configurations

II. A child bean or inherited bean can inherit its parent bean configurations, properties and some
attributes

III. The parent bean allow to override the inherited values

Select One:

a.I, II, and III-------ANS

b.I and II

c.II and III

d.I and III

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

71) which of the following options about Auto wiring in spring are correct?

I. The Auto wiring in spring framework can be performed by configuring in xml and spring Auto-Wiring
with Annotation @Autowired
II. Auto-wiring beans with xml configuration: In Spring framework, you can wire beans automatically
with auto wiring feature

III. To enable auto-wiring just define the "autowire" attribute in <bean> tag.

Select One:

a.I, II, and III--------ANS

b.I and III

c.I and II

d.II and III

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

72) XML Mapping file offers which of the following?

Select One:

a.Readable Metadata

b.Surrogate key generation strategy

c.Collecion metadata

d.all the listed options---------ANS

e.Column/Table Mapping

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

73) Which of the following explains about addClass function in the listed options

I. This function translates a Java class name into file name

II. This translated file name is then loaded as an input stream from the java class loader

III. This addClass function is important if you want efficient usage of classes in your code
Select One

a. I, II, and III--ans

b. I and III

c. I and II

d. II and III

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

74) The application is designed around an object model. The SQL code is generated at build time and the
associations between objects are supported by the persistent mechanism, and queries are specified
using an object oriented expression language. This best suited for medium-sized applications with some
complex transactions. Used when the mappping exceeds 25 different databse products at a time.

Which of the following is this called as?

Select One:

a. Application Object Mapping

b. Expression object mapping

c. Medium Object Mapping--------------ANS

d. Object Mapping

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------
Expected Questions:

1). In Spring AOP, 4 type of advices are supported :

before--------------Run advice before the method execution.

after---------------Run advice after the method execution, regardless of its outcome.

after-returning advice----------Run advice after the method execution, only if the method completes
successfully.

after-throwing advice-----------Run advice after the method execution, only if the method exits by
throwing an exception.

around--------------------------Run advice before and after the advised method is invoked.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

2). ResourceLoader support: Spring's Resource interface us a flexible generic abstraction for handling
low-level resources. An application context itself is a ResourceLoader, Hence provides an application
with access to deployment-specific Resource instances.

MessageSource support: The application context implements MessageSource, an interface used to


obtain localized messages, with the actual implementation being pluggable.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

3).Which of the following are the best practices for writing spring XML Configurations?

1) Add a header comment to each configuration file

2) Use consistent naming conventions

3) No version numbers in schema references

4) Prefer setter injection over constructor injection


5) Prefer type over index for constructor argument matching

6) Use shortcut forms over expanded forms

7) Reuse bean definitions as much as possible

8) Always use ids as bean identifiers

9) Try to avoid autowiring

10) Always use classpath prefix

11) Always externalize properties

12) Use dependency-check at the development phase

13) Do not abuse/overuse dependency injection

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

4). Spring framework architecture:

Data Access/Integration--JDBC,ORM,OXM,JMS, Transactions

Web(MVC/Remoting)--WebSocket,Servlet,Web, Portlet

AOP

Aspects

Instrumentation

Messaging

Core container--Beans,Core, Context,spEL

Test

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

5)

Spring BeanFactory Container-org.springframework.beans.factory.BeanFactoryinterface.

Spring ApplicationContext Container-org.springframework.context.ApplicationContext


------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

6)Bean Scopes:

Scope Description

singleton This scopes the bean definition to a single


instance per Spring IoC container (default).

prototype This scopes a single bean definition to have any


number of object instances.

request This scopes a bean definition to an HTTP


request. Only valid in the context of a web-aware Spring
ApplicationContext.

session This scopes a bean definition to an HTTP


session. Only valid in the context of a web-aware Spring
ApplicationContext.

global-session This scopes a bean definition to a global HTTP


session. Only valid in the context of a web-aware Spring
ApplicationContext.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

7) Spring-Injecting Collection:

Element Description
<list> This helps in wiring i.e., injecting a list of values,
allowing duplicates.

<set> This helps in wiring a set of values but without


any duplicates.

<map> This can be used to inject a collection of name-


value pairs where the name and the value can be of any type.

<props> This can be used to inject a collection of


name-value pairs where the name and the value are both Strings.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

8) Autowiring Modes:

Mode Description

no This is a default setting which means no


autowiring and you should use explicit bean reference for wiring. You
have to do nothing special for this wiring. This is what you already have seen in
Dependency Injection chapter.

byName Autowiring by property name. Spring


container looks at the properties of the beans on which autowire attribute
is set to byName in the XML configuration file. It then tries to match and
wire its properties with the beans defined
by the same names in the configuration file.

byType Autowiring by property datatype. Spring


container looks at the properties of the beans on which autowire
attribute is set to byType in the XML configuration file. It then tries to match
and wire a property if its type matches
with exactly one of the beans name in the configuration file. If more than one such beans exists,

a fatal exception is thrown.


constructor Similar to byType, but this type applies to
constructor arguments.If there is not exactly one bean of the
constructor argument type in the container, a fatal error is raised.

autodetect Spring first tries to wire using autowire by


constructor, if it does not work, Spring tries to autowire by
byType.

Autowiring Limitations:

Limitations Description

Overriding possibility You can still specify dependencies using


<constructor-arg> and <property> settings which will always override
autowiring.

Primitive data types You cannot autowire so-called simple


properties such as primitives, Strings, and Classes.

Confusing nature Autowiring is less exact than explicit wiring, so if


possible prefer using explict wiring.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

9) @Required-----The @Required annotation applies to bean property setter methods

@Autowired----The @Autowired annotation can apply to bean property setter methods, nonsetter
methods, constructor and properties.

@Qualifier----The @Qualifier annotation along with @Autowired can be used to remove the confusion
by specifiying which exact bean will be wired.
JSR-250 Annotations----Spring supports JSR-250 based annotations which include @Resource,
@PostConstruct and @PreDestroy annotations.(Go through these annotations
also)

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

10) @Configuration-----indicates that the class can be used by the Spring IoC container as a source of
bean definitions.

@Bean--------------annotation tells Spring that a method annotated with @Bean will return an object
that should be registered as a bean in the Spring application context

@Import------------annotation allows for loading @Bean definitions from another configuration class

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

11) Spring Event Handling:

ContextRefreshedEvent-----This event is published when the ApplicationContext is either initialized or


refreshed. This can also be raised using the refresh() method on the
ConfigurableApplicationContext interface.

ContextStartedEvent-------This event is published when the ApplicationContext is started using the


start() method on the ConfigurableApplicationContext interface. You can poll your
database or you can restart any stopped application after receiving this event.

ContextStoppedEvent-------This event is published when the ApplicationContext is stopped using the


stop() method on the ConfigurableApplicationContext interface. You can do the required
housekeep work after receiving this event.
ContextClosedEvent--------This event is published when the ApplicationContext is closed using the close()
method on the ConfigurableApplicationContext interface. A closed context reaches its
end of life; it cannot be refreshed or restarted.

RequestHandledEvent-------This is a web-specific event telling all beans that an HTTP request has been
serviced.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

12) AOP Terminologies:

Terms Description

Aspect This is a module which has a set of APIs


providing cross-cutting requirements. For example, a logging module
would be called AOP aspect for logging. An application can have any number of
aspects depending on the

requirement.

Join Point This represents a point in your application


where you can plug-in the AOP aspect. You can also say, it is the
actual place in the application where an action will be taken using Spring AOP
framework.

Advice This is the actual action to be taken either


before or after the method execution. This is an actual piece of
code that is invoked during the program execution by Spring AOP framework.

Pointcut This is a set of one or more join points where an


advice should be executed. You can specify pointcuts using
expressions or patterns as we will see in our AOP examples.
Introduction An introduction allows you to add new methods
or attributes to the existing classes.

Target Object The object being advised by one or more


aspects. This object will always be a proxied object, also referred to
as the advised object.

Weaving Weaving is the process of linking


aspects with other application types or objects to create an advised object.
This can be done at compile time, load time, or at runtime.

------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------

13) Custom Aspects Implementation:

Approach Description

XML Schema based Aspects are implemented using the


regular classes along with XML based configuration.

@AspectJ based @AspectJ refers to a style of


declaring aspects as regular Java classes annotated with Java 5
annotations.

------------------------------------------------------------------------------------------------------------------------------------------
----------------------------

14) Spring Transaction Management:

ACID:
Atomicity: A transaction should be treated as a single unit of operation, which

means either the entire sequence of operations is successful or unsuccessful.

Consistency: This represents the consistency of the referential integrity of the

database, unique primary keys in tables, etc.

Isolation: There may be many transaction processing with the same data set at

the same time. Each transaction should be isolated from others to prevent data

corruption.

Durability: Once a transaction has completed, the results of this transaction have

to be made permanent and cannot be erased from the database due to system

failure.

Methods and description:

TransactionStatus getTransaction(TransactionDefinition definition) This method returns a currently


active transaction or creates a new one,according to the
specified propagation behavior.

void commit(TransactionStatus status) This method commits the given


transaction, with regard to its status.

void rollback(TransactionStatus status) This method performs a


rollback of the given transaction.

int getPropagationBehavior() This method returns the


propagation behavior. Spring offers all of the transaction propagation
options familiar from EJB CMT.
int getIsolationLevel() This method returns the degree
to which this transaction is isolated from the

work of other transactions.

String getName() This method returns the name


of this transaction.

int getTimeout() This method returns the time in


seconds in which the transaction must complete.

boolean isReadOnly() This method returns whether


the transaction is read-only.

------------------------------------------------------------------------------------------------------------------------------------------
----------------------------

15)

isolation levels:

TransactionDefinition.ISOLATION_DEFAULT This is the default


isolation level.

TransactionDefinition.ISOLATION_READ_COMMITTED Indicates that dirty


reads are prevented; non-repeatable reads and phantom reads can occur.

TransactionDefinition.ISOLATION_READ_UNCOMMITTED Indicates that dirty


reads, non-repeatable reads, and phantom reads can occur.

TransactionDefinition.ISOLATION_REPEATABLE_READ Indicates that dirty


reads and non-repeatable reads are prevented; phantom reads can occur.
TransactionDefinition.ISOLATION_SERIALIZABLE Indicates that dirty reads, non-
repeatable reads, and phantom reads are prevented.

------------------------------------------------------------------------------------------------------------------------------------------
----------------------------

16) propagation types:

TransactionDefinition.PROPAGATION_MANDATORY Supports a current


transaction; throws an exception if no current transaction exists.

TransactionDefinition.PROPAGATION_NESTED Executes within a nested


transaction if a current transaction exists.

TransactionDefinition.PROPAGATION_NEVER Does not support a


current transaction; throws an exception if a current transaction exists.

TransactionDefinition.PROPAGATION_NOT_SUPPORTED Does not support a


current transaction; rather always execute nontransactionally.

TransactionDefinition.PROPAGATION_REQUIRED Supports a current


transaction; creates a new one if none exists.

TransactionDefinition.PROPAGATION_REQUIRES_NEW Creates a new


transaction, suspending the current transaction if one exists.

TransactionDefinition.PROPAGATION_SUPPORTS Supports a current


transaction; executes non-transactionally if none exists.

TransactionDefinition.TIMEOUT_DEFAULT Uses the default


timeout of the underlying transaction system, or none if timeouts are not
supported.
------------------------------------------------------------------------------------------------------------------------------------------
----------------------------
SPRING MOCK TEST
http://www.tutorialspoint.com Copyright © tutorialspoint.com

This section presents you various set of Mock Tests related to Spring 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.

SPRING MOCK TEST III

Q 1 - What is Introduction?

A - An introduction represents a point in your application where you can plug-in AOP aspect.

B - This is used to inject values in objects.

C - This is not invoked during program execution by Spring AOP framework.

D - An introduction allows you to add new methods or attributes to existing classes.

Q 2 - What is Target object?

A - A represents a object in your application where you can plug-in AOP aspect.

B - The object being advised by one or more aspects, this object will always be a proxy object,
also referred to as the advised object.

C - This is used to inject values in objects.

D - This is not invoked during program execution by Spring AOP framework.

Q 3 - What is Weaving?

A - Weaving is the process of injecting values in objects to create an advised object.

B - Weaving is the process of linking aspects with other application types or objects to create an
advised object.

C - This is used to inject values in objects.

D - Weaving is used to check object dependencies.

Q 4 - What are the different points where weaving can be applied?

A - Compile time, load time


B - Compile time, run time

C - Run time

D - Compile time, load Time, Run time

Q 5 - What are the types of advice?

A - then, after, after-returning, after-throwing, around

B - When, after, after-returning, around

C - Where, after, after-returning, after-throwing, around

D - Before, after, after-returning, after-throwing, around

Q 6 - How before advice works?

A - Run advice before a class loads.

B - Run advice before a method execution.

C - Run advice before http response is to be returned.

D - Run advice before http request is to be processed.

Q 7 - How after-returning advice works?

A - Run advice after a class loads only if class loads successfully.

B - Run advice after a method execution only if method completes successfully.

C - Run advice after http response is returned only if http response is success.

D - Run advice after http request is processed with no exception.

Q 8 - How after-throwing advice works?

A - Run advice after a method execution only if method exits by throwing an exception.

B - Run advice after a class loads only if class throws exception during load time.

C - Run advice after http response is returned with error status.

D - Run advice after http request is processed and an exception occurred.

Q 9 - How around advice works?

A - Run advice before and after the advised method is invoked.

B - Run advice before and after a class is loaded.

C - Run advice before and after http response is returned.

D - Run advice before and after http request is processed.


Q 10 - Which of the following aspect implementation spring supports?

A - XML Schema based aspect implementation

B - @AspectJ based aspect implementation

C - Both of above.

D - None of above.

Q 11 - What are the types of the transaction management Spring supports?

A - Programmatic transaction management

B - Declarative transaction management

C - Both of above.

D - None of above.

Q 12 - What is Spring MVC framework?

A - Spring MVC framework is Model-Value-Class architecture and used to bind model data with
values.

B - The Spring web MVC framework provides model-view-controller architecture and ready
components that can be used to develop flexible and loosely coupled web applications.

C - Spring MVC framework is used for Transaction management for Web Applications.

D - Spring MVC framework is used for AOP for Web Applications.

Q 13 - What is @Controller annotation?

A - The @Controller annotation indicates that a particular class serves the role of a controller.

B - The @Controller annotation indicates how to control the transaction management.

C - The @Controller annotation indicates how to control the dependency injection.

D - The @Controller annotation indicates how to control the aspect programming.

Q 14 - What are the ways to access Hibernate by using Spring?

A - Inversion of Control with a Hibernate Template and Callback.

B - Extending HibernateDAOSupport and Applying an AOP Interceptor node.

C - Both of above.

D - None of above.

Q 15 - Which ORM Spring supports ?

A - Hibernate

B - iBatis

C - JPA
D - All of above.

E - None of above.

Q 16 - Which of the following database is not supported using jdbcTemplate?

A - MySql

B - PostgresSql

C - NoSql

D - Oracle

Q 17 - How to get object of a service in spring framework?

A - Using new keyword

B - Using dependency injection

Q 18 - Which of the following is part of Data Access layer in Spring framework?

A - Beans

B - Aspects

C - JMS

D - Context

Q 19 - How to use ref keyword in beans.

xml?

A - Using setter method only.

B - Using constructor argument only.

C - Using setter method and constructor argument both.

D - None of the above.

Q 20 - Core container has AOP as one of its module.

A - True

B - False

Q 21 - SpEL is part of core container.

A - False

B - True
Q 22 - Which class acts as IoC Container?

A - ServletContext

B - DispatcherServlet

C - ApplicationContext

D - None of the above

Q 23 - What stands true for spring framework?

A - Spring framework is a light weight framework.

B - Spring framework is a heavy weight framework.

Q 24 - Expression Language/ SpEL was introduced in which version of spring


framework.

A - 1.0

B - 2.0

C - 3.0

D - 4.0

Q 25 - Can we integrate Struts with Spring.

A - Yes

B - No

Q 26 - By default a bean is lazily loaded.

A - True

B - False

Q 27 - By default a bean is eagerly loaded.

A - False

B - True

Q 28 - If a bean is scoped to HTTP request, scope is

A - session

B - global-session

C - prototype

D - request
Q 29 - If a bean is created once per Ioc Container, scope is

A - singleton

B - global-session

C - prototype

D - request

Q 30 - Thread scoped bean is introduced in which version of spring framework.

A - 1.0

B - 2.0

C - 3.0

D - 4.0

Q 31 - If a bean can be created any number of times, scope is

A - session

B - global-session

C - prototype

D - request

Q 32 - What is the scope of stateless bean?

A - global-session

B - singleton

C - prototype

D - request

Q 33 - What is the scope of stateful bean?

A - session

B - global-session

C - prototype

D - request

Q 34 - If a bean is scoped to HTTP session, scope is

A - global-session

B - session

C - prototype

D - request
Q 35 - How to handle shut down of IoC container?

A - Using shutdownHook

B - Using shutdownHandler

C - Using registerHook

D - Using registerShutdownHook

Q 36 - How bean life cycle can be controlled?

A - Using init only

B - Using InitializingBean class only

C - Using DisposableBean class only

D - Using All of above

Q 37 - What is the scope of bean in portlet context?

A - session

B - global-session

C - prototype

D - request

Q 38 - How after advice works?

A - Run advice after a method execution regardless of its outcome.

B - Run advice after a class loads.

C - Run advice after http response is returned.

D - Run advice after http request is processed.

Q 39 - Which class is used to map a database row to a java object in spring?

A - ResultSet

B - RowMapper

C - RowSetMapper

D - ResultSetMapper

Q 40

A bean must have id attribute in beans configuration file.

A - True
B - False

Q 41 - Which of the following class can be used to execute Sql queries in spring?

B - JDBCHelper

A - JdbcTemplate

C - DBHelper

D - DBTemplate

Q 42 - Which of the following class can be used to call Stored Procedures in spring?

A - SPHelper

B - JdbcTemplateCall

C - JdbcTemplate

D - SimpleJdbcCall

Q 43 - What is a DispatcherServlet?

A - DispatcherServlet is used for transaction management.

B - DispatcherServlet is used for AOP.

C - DispatcherServlet handles all the HTTP requests and responses.

D - DispatcherServlet is used for Dependency injection.

Q 44 - What is ACID in transactional management?

A - Accurate, Controlled, Isolation, Durability

B - Atomicity, Consistency, Independent, Done

C - Atomicity, Consistency, Isolation, Durability

D - Accurate, Controlled, Independent, Done

Q 45 - Where do you define DispatcherServlet?

A - In Beans configuration file.

B - Web.xml file

C - Meta-inf/dispatcher.xml

D - Web-inf/ dispatcher.xml

Q 46 - What is true about BeanPostProcessor?

A - It is a concrete class.

B - It is an interface.
C - It is an abstract class.

D - None of the above.

Q 47 - What BeanPostProcessor does?

A - It processes beans once a bean is initialized.

B - It defines callback methods that you can implement to provide your own instantiation logic,
dependency-resolution logic etc.

C - It processes beans once a bean is loaded.

D - It processes beans once a bean exits.

Q 48 - Can be bean be configured to have an inner bean?

A - True

B - False

Q 49 - Can we inject value and ref both together in a bean?

A - True

B - False

Q 50 - Following class can be extended to create custom event in spring.

A - SpringEvent

B - Event

C - ApplicationEvent

D - None of above

ANSWER SHEET

Question Number Answer Key

1 D

2 B

3 B

4 D

5 D

6 B

7 B

8 A
9 A

10 C

11 C

12 B

13 A

14 C

15 D

16 C

17 B

18 C

19 C

20 B

21 B

22 C

23 A

24 C

25 A

26 B

27 B

28 D

29 A

30 C

31 C

32 B

33 C

34 B

35 D

36 D

37 B

38 A

39 B

40 B

41 A

42 D

43 C
44 C

45 B

46 B

47 B

48 A

49 A

50 C

Loading [MathJax]/jax/output/HTML-CSS/jax.js
Core Spring 3.0 Certification Mock Exam

Question
Container

Question 1

Given the following Spring configuration file, what is the correct answer:

<bean class="com.spring.service.MyServiceImpl">
<property name="repository" ref="jpaDao"/>
</bean>

<bean class="com.spring.repository.JpaDao"/>

1. The first declared bean MyServiceImpl is missing an id must be named myService


2. The second declared bean JpaDao is missing an id must be named jpaDao
3. Answers 1 and 2 are both rights
4. Answers 1 and 2 are both wrong

Question 2

Given the Spring configuration file, which are the correct statements?

<bean class="com.spring.service.BankServiceImpl"
p:bankName="NationalBank">
</bean>

1. The p namespace has to be declared


2. Bean id is bankServiceImpl
3. The BankServiceImpl references a NationalBank bean
4. NationalBank is a scalar value

Question 3

How is named the bean that is defined in the following configuration class. Select a single answer.

@Configuration
public class ApplicationConfig {

@Autowired
private DataSource dataSource;

@Bean
ClientRepository clientRepository() {
ClientRepository accountRepository = new JpaClientRepository();
accountRepository.setDataSource(dataSource);
return accountRepository;
}
}

1. JpaClientRepository
2. jpaClientRepository
3. clientRepository
4. Two beans are defined : a data souce and a repository

Question 4

How could you externalize constants from a Spring configuration file or a Spring annotation into a
.properties file? Select one or more answers

1. By using the <util:constant /> tag


2. By declaring the ConstantPlaceholderConfigurer bean post processor
3. By using the <context:property-placeholder /> tag
4. By using the c: namespace

Question 5

What statement is not correct in live environment? Select a unique answer.

1. Constuctor and properties autowiring in the same bean are not compatible
2. A bean should have a default or a no-args constructor
3. The <constructor-arg> tag could take type, name and index to reduce ambiguity
4. None of the above
5. All of the above

Question 6

What are the right affirmations about the @PostConstruct, @Resource and the @PreDestroy
annotations?

1. Those annotations are specified in the JSR-250


2. The Spring Framework embedded those annotation
3. The <context:component-scan> tag enable them
4. The <context:annotation-config > tag enable them
5. Declaring the CommonAnnotationBeanPostProcessor enable them

Question 7

What is/are typically case(s) where you usually need to manually instanciated an ApplicationContext?

1. In a web application
2. In an integration test running with the SpringJUnit4ClassRunner
3. In a standalone application started with a main method
4. None of the above
Question 8

Select the right statement about referring a Spring configuration file inside the package
com.example.myapp in the below example?
ApplicationContext context = new
ClassPathXmlApplicationContext("classpath:/com.example.myapp.config.xml");

1. The classpath: prefix could be omit


2. Package name with dot is not well formatted using the dot character
3. The slash character preceding com.example could be omit
4. All of the above
5. None of the above

Question 9

How to auto-inject into a field a bean by its name? Select one or more response.

1. With the name attribute of the @Autowired annotation


2. By using the single @Qualifier annotation
3. By using both the @Autowired and the @Qualifier spring annotations
4. By using the @Autowired annotation and naming the field with the bean name

Question 10

What are the main advantages of using interfaces when designing business services? Select one or
more answers.

1. Mocking or stubbing the service


2. Be able to use the Spring auto-injection
3. Can do dependency checking
4. Loosely coupled code

Question 11

Select one or many correct answers about spring bean life cycle.

1. The method annoted with @PostConstruct is called after bean instantiation and before
properties setting of the bean
2. The method @PreDestroy of a prototype bean is called when the bean is garbage collected
3. The init() method declared in the init-method attribute of a bean is called before the
afterPropertiesSet callback method of the InitializingBean interface
4. The method annotated with @PostConstruct is called before before the afterPropertiesSet
callback method of the InitializingBean interface

Question 12

Given the following configuration class, what are correct affirmations? Select one or more answers.
public class ApplicationConfig {

private DataSource dataSource;

@Autowired
public ApplicationConfig(DataSource dataSource) {
this.dataSource = dataSource;
}

@Bean(name="clientRepository")
ClientRepository jpaClientRepository() {
return new JpaClientRepository();
}
}

1. @Configuration annotation is missing


2. Default or no-arg constructor is missing
3. @Bean name is ambiguous
4. @Bean scope is prototype

Question 13

What are the features of the XML <context: namespace? Select one or many answers.

1. @Transactional annotation scanning


2. @Aspect annotation detection enabling
3. @Autowired annotation enabling
4. @Component annotation scanning

Test

Question 14

Select one or more correct statements about developing integration test with Spring support.

1. A new Spring context is created for each test class


2. To get a reference on the bean you want to test, you have to call the getBean() method of
the Spring context
3. Spring context configuration could be inherits from the super class
4. The Spring context configuration file has to be provided to the @ContextConfiguration
annotation

Question 15

What are the main advantage(s) for using Spring when writing integration tests?

1. Reuse Spring configuration files of the application


2. Create mock or stub
3. Be able to use the rollback after the test pattern
4. Use dependency injection
Question 16

What are the main advantage(s) for using Spring when writing unit tests?

1. Reuse Spring configuration files of the application


2. Use dependency injection
3. Provide some mocks for servlet classes
4. All of the above
5. None of the above

Question 17

What is right about the spring test module?

1. It provides an abstraction layer for the main open source mock frameworks
2. Provides the @Mock annotation
3. It dynamically generates mock objects
4. All of the above
5. None of the above

Question 18

Select correct statement(s) about transactional support of the spring test module.

1. Transaction manager could be set within the @TransactionConfiguration annotation


2. Method annotated with @Before is executed outside of the test’s transaction
3. Spring test may rollback the transaction of a service configured with the REQUIRES_NEW
propagation
4. The transaction of a method annotated with the @Rollback annotation with its default
values is rolled back after the method has completed

AOP

Question 19

Considering 2 classes AccountServiceImpl and ClientServiceImpl. Any of these 2 classes inherits from
each other. What is the result of the pointcut expressions?

execution(* *..AccountServiceImpl.update(..))
&& execution(* *..ClientServiceImpl.update(..))

1. Matches pubic update methods of the 2 classes, whatever the arguments


2. Matches any update methods of the 2 classes , whatever the arguments and method
visibility
3. Matches any update methods of the 2 classes , with one more arguments and whatever
method visibility
4. No joint point is defined

Question 20
Using the Spring AOP framework, what is the visibility of the method matches by the following join
point?

@Pointcut("execution(* *(..))")
private void anyOperation() {};

1. All methods, whereas there visibility


2. All methods, except private method
3. Protected and public methods
4. Public methods

Question 21

What are the 2 correct statements about AOP proxy?

1. AOP proxies are created by Spring in order to implement the aspect contracts
2. AOP proxies are always created with a JDK dynamic proxy
3. Only classes that implements a least one interface could be proxied
4. All methods could be proxied
5. Proxies are created by a BeanPostProcessor

Question 22

What is an after throwing advice? Select a unique answer.

1. Advice that could throw an exception


2. Advice to be executed if a method exits by throwing an exception
3. Advice that executes before a join point
4. Spring does not provide this type of advice

Question 23

What is an after returning advice? Select a unique answer.

1. Advice to be executed regardless of the means by which a join point exits


2. Advice that surrounds a method invocation and can perform custom behavior before and
after the method invocation
3. Advice to be executed before method invocation
4. Advice to be executed after a join point completes without throwing an exception

Question 24

What is an advice? Select a unique answer.


1. An action taken by an aspect at a particular join point
2. A point during the execution of a program
3. An aspect and a pointcut
4. A predicate that matches join points

Question 25

What is a pointcut? Select a unique answer.

1. Code to execute at a join point


2. An expression to identify joinpoints
3. An advice and a jointpoint
4. None of the above

Question 26

Select method’s signatures that match with the following pointcut:

execution(* com.test.service..*.*(*))

1. void com.test.service.MyServiceImpl#transfert(Money amount)


2. void com.test.service.MyServiceImpl#transfert(Account account, Money amount)
3. void com.test.service.account.MyServiceImpl#transfert(Money amount)
4. void com.test.service.account.MyServiceImpl#transfert(Account account, Money amount)
5. None of the above

Question 27

What are the unique correct answers about Spring AOP support?

1. An advice could proxied a constructor’s class


2. A point cut could select methods that have a custom annotation
3. Static initialization code could be targeted by a point cut
4. Combination of pointcuts by &&, || and the ! operators is not supported

Question 28

Using the Spring AOP framework, what are the joinpoint methods of the following pointcut
expressions?

execution(public * *(..))

1. The execution of all public method


2. The execution of all public method returning a value
3. The execution of all public method having at least one parameter
4. The execution of all public method in class belonging to the default java package

Data Access

Question 29

Why is it a best practice to mark transaction as read-only when code does not write anything to the
database? Select one or more answers.

1. It is mandatory for using Spring exception translation mechanism


2. May be improve performance when using Hibernate
3. Spring optimizes its transaction interceptor
4. Provides safeguards with Oracle and some other databases

Question 30

What data access technology is supported by the Spring framework? Select one or more answers.

1. JDBC
2. NoSQL
3. Hibernate
4. JPA

Question 31

What is not provided by the JdbcTemplate? Select a unique answer.

1. Data source access


2. Open/close data source connection
3. JDBC exception wrapping into DataAccess Exception
4. JDBC statement execution

Question 32

Using JdbcTemplate, what is the Spring provided class you will use for result set parsing and merging
rows into a single object? Select a unique answer.

1. RowMapper
2. RowCallbackHandler
3. ResultSetExtractor
4. ResultSetMapper

Question 33

What configuration is supported by the LocalSessionFactoryBean? Select a unique answer.

1. Listing entity classes annoted with @Entity


2. Scanning a package to detect annoted entity classes (with @Entity)
3. Listing hibernate XML mapping configuration file (.hbm.xml)
4. All above

Transaction

Question 34

What is/are incorrect statements about XML declaration of the transaction manager bean? Select
one or more answers.

1. The tx namespace provides JTA transaction manager declaration shortcut syntax


2. Id of the bean has to be transactionManager
3. Depending the application persistence technology, the HibernateTransactionManager or the
DataSourceTransactionManager could be used as bean class
4. Default transaction timeout could be given

Question 35

Assuming @Transactional annotation support is enabled and the transferMoney method is called
through a Spring AOP proxy, what is the behavior of the following code sample?

@Transactional(propagation=Propagation.REQUIRED)
public void transferMoney(Account src, Account target, double amount) {
add(src, -amount);
add(src, amount);
}

@Transactional(propagation=Propagation.REQUIRES_NEW)
public void add(Account account, Double amount) {
// IMPLEMENTATION
}

1. The add() method executes code in a new transaction


2. The add() method uses the transaction of the transferMoney() method
3. When calling the add() method, an exception is thrown
4. Other behavior

Question 36

Does Spring provides programmatic transaction management? Select a unique answer.

1. Yes with the TransactionTemplate class


2. Yes with the TransactionService class
3. Yes using the @Transactional bean post processor
4. No

Question 37
What is the transaction behavior of the PROPAGATION_REQUIRES_NEW mode? Select a unique
answer.

1. If a transaction exists, the current method should run within this transaction. Otherwise, it
should start a new transaction and run within its own transaction.
2. If a transaction is in progress, the current method should run within the nested transaction
of the existing transaction. Otherwise, a new transaction has to be started and run within its
own transaction.
3. The current method must start a new transaction and run within its own transaction. If there
is an existing transaction in progress, it is suspended.
4. None of the above

Question 38

What is the default rollback policy in transaction management?

1. Rollback for any Exception


2. Rollback for RuntimeException
3. Rollback for checked exceptions
4. Always commit

Sping @MVC

Question 39

What could not return a Spring MVC controller? Select a single answer.

1. An absolute path to the view


2. A logical view name
3. A new JstlView
4. void
5. null value

Question 40

Where do you cannot declare Spring MVC controller? Select one or more answers.

1. In a Spring application context XML configuration file


2. Into the web.xml file of the web application
3. Into the java code by using annotations
4. Into the JSP pages

Question 41
What is the easiest method to write a unit test?

1. void displayAccount(HttpServletRequest req, HttpServletResponse resp)


throws ServletException, IOException

2. void displayAccount(HttpServletRequest req, HttpSession Session)


throws ServletException, IOException

3. @RequestMapping("/displayAccount")
String displayAccount(@RequestParam("accountId") int id, Model model)

4. @RequestMapping("/displayAccount")
String displayAccount(@PathVariable("accountId") int id, Model model)

Spring Security

Question 42

How could you secure MVC controller with Spring Security? Select a unique answer.

1. With the @Secured annotation


2. With the @RolesAllowed annotation
3. In a XML security configuration file
4. All of the above
5. None of the above

Question 43

What are the possible mechanisms provided by Spring Security to store user details? Select one or
more correct answers.

1. Database
2. JAAS
3. LDAP
4. Properties file

Question 44

What is true about Spring security configuration and the security namespace? Select one or more
correct answers.

1. The access attribute of the intercept-url tag support both EL and constants together.
2. The patterns declared into the intercept-url tag are analyzed from up to bottom. Winning is
the first that matches.
3. The patterns declared into the intercept-url tag use by default the java regex syntax.
4. Security rules may applied depending request parameter

Remoting

Question 45

What do you have to do even if you are using the RMI Spring Remoting support? Select one or more
correct answers.

1. Implements the Remote interface


2. Extends the RemoteObject class
3. Catching the RemoteException exception
4. Implements the Serializable interface

Question 46

What is exact about the HttpInvokerServiceExporter? Select one or more correct answers.

1. Has to run into a HTPP server as Jetty


2. Could process both POST and GET requests
3. Could be used with any http client as Jakarta Commons HttpClient
4. Could consume SOAP http request

JMS

Question 47

What is the method that is not provided by the JmsTemplate Spring class?

1. convertAndSend
2. onMessage
3. receiveAndConvert
4. setDefaultDestination

Question 48

How could you implement a JMS Listener using the Spring JMS support? Select one or more correct
answers.
1. By implementing the javax.jms.MessageListener interface
2. By implementing the SessionAwareMessageListener interface provided by Spring
3. Without any code, only using the jms namespace provided by Spring
4. By writing a single POJO without parent class or interface

JMX

Question 49

What is easier to do by using Spring JMS support? Select one or more correct answers.

1. Register any Spring bean as JMX MBean


2. Register an existing MBean with a MBeanServer
3. Accessing to remote MBean
4. Control the attributes and the operations of a Spring bean exposes as a MBean

Question 50

What is the purpose of the @ManageResource annotation? Select a single answer.

1. Expose a bean’s property (getter/setter) to JMX


2. Expose a bean’s method to JMX
3. Identify a Spring bean as a JMX MBean
4. None of the above
Response

Container

Question 1

Answer 2 is correct. Those beans are anonymous because no id is supplied explicitly. Thus Spring
container generates a unique id for that bean. It uses the fully qualified class name and appends a
number to them. However, if you want to refer to that bean by name, through the use of the ref
element you must provide a name (see Naming Beans section of the Spring reference manual). To be
correct, the 2nd bean has to declare a jpaDao id attribute in order to be reference by the
repository property of the first bean.

Question 2

Answers 1 and 4 are correct.

1. To set bean’s property with the p:propertyName shortcut, you have to declare the
http://www.springframework.org/schema/p in your xml configuration file. No xsd is
required.
2. The bean is anonymous. Spring generates a unique id:
com.spring.service.BankServiceImpl#0
3. To reference another bean with the p namespace, you have to use the p:propertyName-ref
syntax
4. Due to the above explanation, NationalBank is not a bean reference, so it is a simple String
and thus a scalar value.

Question 3

Correct answer is 3.
The @Bean annotation defines a String bean with the id "clientRepository". JpaClientRepository is
the implementation class of the bean. The data source is injected and is not declared in this class.

Question 4

The only possible answer is the number 3.

1. The <util:constant static-field="constant name"/> tag enables to reference a Java constant or


enumeration into a spring configuration file
2. ConstantPlaceholderConfigurer does not exist. You may think about the
PropertyPlaceholderConfigurer bean post processor.
3. The <context:property-placeholder location="file:/myApp.properties" /> tag activates the
replacement of ${...} placeholders, resolved against the specified properties file.
4. The c: namespace is for simplifying constructor syntax (since Spring 3.1) and don’t provide
such feature.

Question 5
The statements number 5 is right.

1. You may auto-wiring properties by constructor, setter or properties in the same bean
2. The <constructor-arg> tag helps to instanciated a bean without default or no-args
constructor
3. The <constructor-arg> tag could take type and index to reduce ambiguity, but not name
which requires debug symbols.

Question 6

Answers 1, 3, 4 and 5 are rights.

1. The @PostConstruct, @PreDestroy and @Resource annotations are defined in the JSR-250
2. They belong to the javax.annotation package. You should add an external jar to use them in
Java 5. Java 6 and 7 integrates them.
3. The <context:component-scan> automatically detects stereotyped classes and turns on the
<context:annotation-config>
4. The <context:annotation-config > activates the Spring infrastructure for various annotations
to be detected in bean classes, including the JSR 250 annotations
5. The CommonAnnotationBeanPostProcessor supports common Java annotations out of the
box, in particular the JSR-250 annotations.

Question 7

Correct answer in the number 3.

1. In a web application, the ContextLoaderListener is in charge to create an


WebApplicationContext.
2. In an integration test based on Spring, the SpringJUnit4ClassRunner creates the application
context for you. The @ContextConfiguration annotation allows to specified application
context configuration files.
3. In a main method, you have to instanciated a class implementing the ApplicationContext
interface (examples: ClassPathXmlApplicationContext or FileSystemXmlApplicationContext)

Question 8

Answer number 4 is right.

1. When using the ClassPathXmlApplicationContext, the classpath: prefix is default one


so you could omit it
2. In a Spring location resource, package separator is a slash and not a dot. Thus the
com/example/myapp/config.xml syntax has to be used.
3. ClassPathXmlApplicationContext starts looking from root of the classpath regardless of
whether specify "/"

Question 9

Answers number 3 and 4 are valid.


1. The @Autowired annotation has no name property, just a required one.
2. Autowiring a field, the @Inject or the @Autowired or the @Resource annotations are
mandatory.
3. The @Qualifier("name") annotation complements the use of the @Autowired annotation by
specifying the name of the bean to inject
4. When 2 beans are eligible to auto-injection, Spring uses the field name to select the
appropriate one.

Question 10

Answers number 1 and 4 are valid.

1. With modern mock API like Mockito or EasyMock, interfaces are not mandatory for mocking
or stubbing the service. But using interface remains easier when you have to manually mock
the service in unit test.
2. Auto-injection is possible with class. Spring uses CGLIB.
3. Dependency checking is an advantage of dependencies injection.
4. The Inversion of Control pattern requires an interface to separate 2 classes. This pattern
provides code more flexible, unit testable, loosely coupled and maintainable.

Question 11

Correct answers: 4

1. In the bean lifecycle, method annotated with @PostConstruct is called after the properties
set step and the BeanPostProcessors#postProcessBeforeInitialization step
2. Destroy methods of prototype beans are never called
3. In the bean lifecycle, the afterPropertiesSet callback method of the InitializingBean is called
after the method annotated with the @PostConstruct annotation and before the init-method
declared in the XML configuration file.
4. In the bean lifecycle, the method annotated with the @PreDestroy annotation is called
before the destroy callback of the DisposableBean interface and before the destroy-method
declared in the XML configuration file.

Question 12

Correct answers are 1 and 2.

1. In order to be taken into account by Spring, the ApplicationConfig class has to be annotated
with the @Configuration annotation
2. Default or no-arg constructor is mandatory. Here, the provided constructor with a
dataSource parameter is not taken into account
3. The bean name is clientRepository. The name property of the @Bean annotation is specified
thus the method name jpaClientRepository is ignored.
4.
Question 13

Correct answers are 3 and 4

1. Use <tx:annotation-driven /> to enable @Transactional annotation scanning


2. Use <aop:aspectj-autoproxy /> to enable detection of @Aspect bean
3. Turns on <context:annotation-config /> or <context:component-scan /> to enable
@Autowiring annotation
4. Turns on <context:component-scan /> to enable @Component annotation scanning

Test

Question 14

The only correct answer is number 3.

1. The Spring context is cached across tests unless you use @DirtiesContext annotation
2. With the Spring test module, dependency injection is available in test case. So you may auto-
wired the bean to test
3. By default, a @ContextConfiguration annoted class inherits the spring context configuration
file locations defined by an annotated superclass. The inheritLocations of this attribute
allows to change this default behavior.
4. If no context configuration file is provided to the @ContextConfiguration annotation, Spring
use a file convention naming. It try to load a file named with the test class name and suffices
by the "-context.xml" suffice (i.e. MyDaoTest-context.xml)

Question 15

Correct answers are 1, 3 and 4.

What are the main advantage(s) for using Spring when writing integration tests?

1. More than testing multiple classes together, integration test may allow to test your spring
configuration file and/or to reuse it.
2. Mocking or stubbing is more frequent in unit tests than in integration tests. And Spring does
not provide any implementation or abstraction of mock framework.
3. The framework may create and roll back a transaction for each test method. Default rollback
policy could be change by using the @TransactionConfiguration annotation. And default
mode could be overridden by the @Rollback annotation.
4. DependencyInjectionTestExecutionListener provides support for dependency injection and
initialization of test instances.

Question 16

The correct answer is the number 3.


What are the main advantage(s) for using Spring when writing unit tests?

1. You don’t need Spring container to writer unit test


2. Refer to the answer number 1.
3. The org.springframework.mock package provides mock classes like MockHttpSession or
MockHttpContext. They could be helpful for unit test in the presentation layer and when you
don’t use any mock framework such as Mockity or EasyMock.

Question 17

Answer 5 is correct.

What is right about the spring test module?

1. The spring test module does not provide an abstraction layer for open source mock
frameworks like EasyMock, JMock or Mockito
2. The @Mock annotations comes from the Mockito framework
3. The spring test module does not provide mechanism to generate mock objects at runtime

Question 18

Correct statements are number 1 and 4.

1. The transactionManager property of the @TransactionConfiguration annotation enable to


set the bean name of the PlatformTransactionManager that is to be used to drive
transactions.
2. Method annotated with @Before is executed inside the test’s transaction. You have to use
the @BeforeTransaction to execute code outside the test’s transaction.
3. The REQUIRES_NEW propagation suspends the current test’s transaction then creates a new
transaction that will be used to execute the service. A commit at the service level could not
be changed by the test.
4. The transaction for the annotated method should be rolled back after the method has
completed.

AOP

Question 19

The correct answer is the number 4.

Considering 2 classes AccountServiceImpl and ClientServiceImpl. Any of these 2 classes inherits from
each other. What is the result of the pointcut expressions?

execution(* *..AccountServiceImpl.update(..))
&& execution(* *..ClientServiceImpl.update(..))

Poincut expression could not satisfied both first and second execution point. Do not confuse the &&
operator and || operator.
Question 20

Correct answer is the number 4.

Due to the proxy-based nature of Spring's AOP framework, protected methods are by definition not
intercepted, neither for JDK proxie nor for CGLIB proxies. As a consequence, any given pointcut will
be matched against public methods only!

To intercept private and protected methods, AspecJ weaving should be used instead of the Spring’s
proxy-bases AOP framework.

Question 21

The 2 correct statements are 1 and 5.

What are the 2 correct statements about AOP proxy.

1. An object created by the AOP framework in order to implement the aspect contracts
2. If the target object does not implement any interfaces then a CGLIB proxy will be created.
You could also use CGLIB proxy instead of JDK dynamic proxy
3. If the target object does not implement any interfaces then a CGLIB proxy will be created.
4. When CGLIB proxy is used, final methods cannot be advised, as they cannot be overridden.
5. AOP Proxies are created by the AbstractAutoProxyCreator#postProcessAfterInitialization
method.

Question 22

The answer number 2 is correct.

1. A before advice could throw an exception


2. An after throwing advice is executed if a method exits by throwing an exception
3. An advice that executes before a join point is named a before advice
4. Spring supports after throwing advices

Question 23

Correct answer: 4

1. This is an after (finally) advice


2. This is an around advice
3. This is a before advice
4. True

Question 24

Correct answer: 1
1. Definition of an advice
2. Definition of a joint point
3. Represents nothing
4. Definition of a point cut

Question 25

Correct answer: 2

1. Definition of an advice
2. Definition of a pointcut
3. Represents nothing

Question 26

Correct answers: 1, 3

Select methods that match with the following pointcut:

execution(* com.test.service..*.*(*))

1. True
2. The pattern (*) matches a method taking one parameter of any type
3. The com.test.service.account sub-package matches the pointcut
4. False for the same reason as answer number 2.

Question 27

Correct answers: 2

1. Interception of constructors requires the use of Spring-driven native AspectJ weaving instead
of Spring's proxy-based AOP framework
2. The @annotation designator enables to select methods that are annotated by a given
annotation
3. The staticinitialization AspectJ designator is not supported by Spring AOP
4. Pointcut expressions can be combined using &&, || and !

Question 28

Correct answers: 1

1. The execution of all public method


2. The * return type pattern indicates any return value or void
3. The (..) param pattern indicates 0, 1 or many parameters
4. No package name is specified. So classes of any package could match.

Data Access

Question 29

Correct answers: 2 , 4

1. Spring exception translation mechanism has nothing to do with read-only transaction


2. Read-only transaction prevents Hibernate from flushing its session. Hibernate do not do dirty
checking and it increases its performance.
3. No
4. When jdbc transaction is marked as read-only, Oracle only accepts SELECT SQL statements.

Question 30

Correct answers: 1, 3, 4

1. JDBC is supported: JdbcTemplate, JDBCException wrapper …


2. Some NoSQL databases are supports through the Spring Data project
3. Hibernate is supported: HibernateTemplate, AnnotationSessionFactoryBean …
4. JPA is supported: LocalEntityManagerFactoryBean, @PersistenceContext annotation support

Question 31

Correct answer: 1

1. A JdbcTemplate requires a DataSource as input parameters


2. JdbcTemplate uses the probided datasource to open then close a JDBC connection
3. Callback methods of JdbcTemplate throw SQL Exception and Spring converts into
DataAccessException
4. For example, the queryForInt method executes an SQL statement

Question 32

Correct answer: 3

1. RowMapper : result set parsing when need to map each row into a custom object
2. RowCallbackHandler : result set parsing without returning a result to the JdbcTemplate caller
3. ResultSetExtractor : for result set parsing and merging rows into a single object
4. ResultSetMapper : this class does not exist

Question 33
Correct answer: 3

1. False. This is supported by the AnnotationSessionFactoryBean using annotedClasses


2. False. This is supported by the AnnotationSessionFactoryBean using packagesToScan
3. True using mappingLocations
4. False

Transaction

Question 34

Correct answer: 2

1. <tx:jta-transaction-manager />
2. Id of the transaction manager bean could be customized (ie. txManager)
3. DataSourceTransactionManager is a transaction manager for a JDBC data source.
HibernateTransactionManager may be used to manage transaction with Hibernate.
4. The AbstractPlatformTransactionManager has a defaultTimeout property that could be
customized

Question 35

Correct answer: 2

In proxy mode, only external method calls coming in through the proxy are intercepted. In the code
snippet, the add() method is self-invocated. This means that, the @Transactional annotation of the
add() method is not interpreted. The REQUIRES_NEW propagation level is not taken into account.
To summary, when the transferMoney() methods calls add() method directly, the transaction
attributes of add() method are not used

Question 36

Correct answer: 1

1. The TransactionTemplate class provides an execute(TransactionCallback) method


2. The TransactionService class does not exists
3. The @Transactional annotation is for declarative transaction management

Question 37

Correct answer: 3

1. PROPAGATION_REQUIRED
2. PROPAGATION_NESTED
3. PROPAGATION_REQUIRES_NEW

Question 38
Correct answer: 2

1. False.
2. True
3. False
4. False

Sping @MVC

Question 39

Correct answer: 1

1. Spring does not allow to return an absolute path to the view


2. Controller could return a String that matches with a logical view name
3. A JstlView with the .jsp path (i.e. /WEB-INF/accountList.jsp)
4. void forward to the default view
5. null forward to the default view

Question 40

Correct answer: 2, 4

1. Spring MVC controllers are beans. So you can declare them into a Spring application context
XML configuration file that could be loaded by the DispatcherServlet.
2. In the web.xml, you may declarer and a ContextLoaderListener and a DispatcherServlet that
are in charge to load XML Spring configuration files. But you cannot declare controllers
directly in these file.
3. The @Controller annotation may be used to annoted Spring MVC Controller beans that
handle HTTP requests.
4. JSP is the View of the MVC Pattern. Thus this is not the right place to declare controllers.

Question 41

Correct answer: 3

1. HttpServletRequest and HttpServletResponse have to be mocked. Id of the account to display


could be set into the http request parameters.

2. HttpServletRequest and HttpSession have to be mocked. Id of the account to display could be


set into the http request parameters.

3. This method is not dependent of the servlet API. Id of the account to display may be directly
passed through the call stack. Thus test methods are simplified.
4. The @PathVariable annotation has to be bound to a URI template variable. This is not the
case.

Sping Security

Question 42

Correct answer: 4

1. @Secured annotation is a Spring Security annotation


2. @RolesAllowed is a JSR-250 annotation that is supported by Spring Security
3. Spring Security could be configured in a XML way to intercept particular URLs

Question 43

Correct answer: 1, 2, 3 and 4

Question 44

Correct answer: 2

1. You cannot mix EL and constant in the same configuration file


2. If more than one intercept-url matches, the top one is used
3. Ant pattern is used by default. But you can change to use regular expression.
4. Security rules may apply to request URL, request method (GET, POST …) but not to request
parameters.

Remoting

Question 45

Correct answer: 4

1. No more interface to implement. RMI Client and Server could be POJO.


2. No more class to extend. RMI Client and Server could be POJO.
3. Spring Remoting wraps the cheched RemoteException into RuntimeExcpetion.
4. Object that are transferred via RMI are serializabled/unserializabled. So they have to
implement the Serializable interface.

Question 46
Correct answers: 1, 3

1. HttpInvokerServiceExporter requires a HTTP web server to process incoming http request.


Tomcat or Jetty is possible candidates. Spring also supports the Oracle/Sun's JRE 1.6 HTTP
server.
2. Only the POST method is supported. Maybe due to the 256 characters limit of the GET
method.
3. Spring comes with 2 http client implementations: for Commons HttpClient and classic JavaSE
API. You can create a custom one by extending the AbstractHttpInvokerRequestExecutor
class.
4. Does not support SOAP web service. Use the Spring web service module or use the JAX-WS
or JAX-RPC remoting support.

JMS

Question 47

Correct answer: 2

1. The convertAndSend method sends a given object to a destination, converting the object to
a JMS message.
2. The onMessage method does not exist.
3. The receiveAndConvert method receives a message synchronously then convert the
message into an object
4. The setDefaultDestination method sets the destination to be used on send/receive
operations that do not have a destination parameter.

Question 48

Correct answers: 1, 2 , 4

1. The javax.jms.MessageListener interface could be used with the


SimpleMessageListenerContainer
2. The SessionAwareMessageListener interface could be used with
DefaultMessageListenerContainer and SimpleMessageListenerContainer
3. Business code is required to handle and process the JMS message.
4. A JMS Listener could be a POJO. The name of the handler method to invoke has to be
specified in the <jms:listener /> tag.

JMX

Question 49

Correct answers: 1, 2, 3, 4

1. The MBeanExporter class allow to expose any Spring bean as a JMX MBean
2. Exiting MBean could be declared as Spring bean. Then the <context:mbean-export />
directive enables their registration to the MBeanServer
3. Remote MBean could be access through a proxy
4. Implementations of the MBeanInfoAssembler interface do the job

Question 50

Correct answer: 3

1. @ManageAttribute exposes a bean’s property (getter/setter) to JMX


2. @ManageOperation exposes a bean’s method to JMX
3. @ManageResources identify a Spring bean as a JMX MBean

You might also like