Elance Spring Framework Test Answers



Which of these resource prefixes could be used?

classpath:
All of these
file:
http:

 

 

Which of the following correctly describes JobLauncher?

It represents a running instance of a Job
It provides parameters that are used by the JobInstance
It helps in launching a job and uses JobRepository to obtain a valid JobExecution
It stores JobInstances and JobExecutions

 

 

True or false? Spring's DAO classes translate SQL exceptions into general Spring exceptions

True
FALSE
sometimes True

 

 

Which of the following is NOT a way to use Spring Web MVC's asynchronous request processing?

Inject a TaskExecutor and pass it to the Session
Return a DeferredResult from the @RequestMapping method
Return a Callable from the @RequestMapping method

 

 

Which of the of the following is not a wiring mode supported by Spring?

by property
by type
by name
by constructor

 

 

Which of the following is NOT true about Spring Web Services?

Supports WS-Security
Supports integration with Acegi Security
Provides flexible XML Marshalling
Spring-WS require Spring 2.x or higher

 

 

Which one of the following statements is NOT true?

@ModelAttribute can be used on method parameters in a controller
@Value annotation can be used on a class
@Value annotation can be used on a field
@ModelAttribute can be used on methods in a controller

 

 

Which of the following is NOT a valid spring bean scope?

prototype
singleton
localSession
globalSession

 

 

In "<property name="initialShapeSeed" value="#{ numberGuess.randomNumber }"/>", what is the name of the notation used to define the value of the property?

SpEL
JSF
DAO
JSP

 

 

Which of the following statements BEST describes Spring Bean Factory?

Spring Bean Factory creates association between collaborating objects as they are instantiated but does NOT publish events to beans that are registered as listeners
Spring Bean Factory provides a means for resolving text messages, including support for i18n of those messages, provide generic way to load file resources
Spring Bean Factory does NOT create association between collaborating objects as they are instantiated and does NOT publish events to beans that are registered as listeners
Spring Bean Factory creates association between collaborating objects as they are instantiated and publish events to beans that are registered as listeners

 

 

Which of the following is NOT a method of using transactions in Spring?

programmaticly
proxies
declaratively

 

 

What does the ${...} placeholder usually signify?

Java system property
property is read from a configuration file
value is a HTTP parameter

 

 

How do you refer to a collection in a Spring bean definition?

<lists> <ref bean="one" /> </lists>
<list> <ref bean="one" /> </list>
None of these
<list> <reference bean="one" /> </list>

 

 

spring-test uses what common convention to allow testing using HTTP session and HTTP request objects?

MVC
DAOs
Open-closed principle
Mock objects

 

 

How does Spring handle XML marshalling/unmarshalling?

wraps a variety of libraries, including Jackson and JAXB
does not support marshalling/unmarshalling
provides its own fast, easy XML marshaller/unmarshaller

 

 

Which of the following annotations can be used to declare a bean in Spring?

@Component, @Controller, and @Service
@Component and @Controller
@Componet, @Controller, @Service, and @Repository
@Component

 

 

If a Spring bean implements BeanFactoryAware, which method is called with the bean instance?

setFactory()
setBeanInstance()
setBeanFactory()
setInstance()

 

 

What is the @Valid annotation used for?

Validating @Controller inputs
In tests to verify objects
In mock objects

 

 

True or False? Spring supports joda-time.

True
FALSE

 

 

Spring's caching support does what?

is not thread-safe
provides its own caching implementation
abstracts a variety of different caching implementations

 

 

Spring's JdbcTemplate is central class to interact with a database through JDBC. How can it be created?

JdbcTemplate template = new JdbcTemplate(myDataSource);
JdbcTemplate template = new JdbcTemplate(myDatabase);
JdbcTemplate template = new JdbcTemplate();
JdbcTemplate template = new JdbcTemplate(myConnection);

 

 

True or False? Spring Integration is a part of the Spring framework you must use if you want to use beans.

TRUE
False

 

 

Which of these is NOT a Spring annotation?

@Service
@Controller
@View
@Component
@Aspect

 

 

Imagine I have multiple classes that have similar properties; what's a good way of handling this situation without copy/pasting the bean definitions?

use bean inheritance
write some code
write a custom BeanResolver
use AOP

 

 

How can you instantiate BeanFactory?

Using ClassPathXmlApplicationContext.
Using XmlFileApplicationContext.
Using FileSystemXmlApplicationContext or ClassPathXmlApplicationContext.
Using FileSystemXmlApplicationContext.

 

 

Which if the most common scope for DAO beans?

singleton
session
request
prototype

 

 

To enable MVC Java config, @EnableWebMvc should be used with which of following annotation?

@Resource
@Configuration
@Componet
@Controller

 

 

Which of these is NOT a Spring Bean Scope?

session
response
request
prototype
singleton

 

 

By default when singleton bean is instantiated?

when bean is accessed
in compile-time
app context is created

 

 

DispatcherServlet class follows which design pattern?

Singleton
Template
Factory
FrontController
Abstract factory

 

 

In Spring MVC, what is responsible for handling HTTP requests and responses?

RequestHandler
DispatcherServlet
SpringController
HttpServlet

 

 

Exceptions thrown by the Spring DAO classes are subclasses of which?

DataAccessException
DataException
AccessException
DAOException

 

 

What are the different types of bean injection?

By setter, By getter
By constructor, By builder
By setter, By constructor ,By builder
By setter, By constructor

 

 

Which of the following is NOT a scope available in Spring web applications?

singleton
request
instance
session

 

 

Which of the following is an advantage of using Spring's transaction management?

forces you to use Hibernate
can easily switch between JTA and regular transactions
you can customize the lifecycle
it's faster

 

 

Which of the following best describes @Order annotation?

Specifies the scope of a bean
Guides autowiring to be performed by means other than by type
Typically used to inject the properties of domain objects
Defines ordering as an alternative to implementing the org. springframework.core.Ordered interface

 

 

What is the default scope of a Spring bean?

Session
Singleton
None of these
Prototype
Abstract

 

 

Which one of the following statements is NOT true about MVC pattern?

Model represents the business data as well as the "state" of the application
View represents the data to the user in the desired format, supports interactions with users.
MVC stands for Model, View, and Controller
The controller's main responsibility is to interact with the database like performing CRUD operations.

 

 

Which is an embedded database supported by Spring?

PostgreSQL
Oracle
HSQL
MySQL

 

 

What does the @Valid as part of JSR-303 mean?

input will be validated using registered validators for that type
sent to the database for constraint validation
uses Spring Security to validate security constraints

 

 

Which of the following is BAD practice, in general?

continuous integration
all beans are prototype scope
minimizing inter-dependencies between beans

 

 

What is JdbcTemplate used for?

executing SQL statements against the database
configuring JDBC
configuring the connection pool using defaults

 

 

Which of the following is an INVALID @RequestMapping declaration?

@RequestMapping(value = { "/" }, headers = "Accept=text/html")
@RequestMapping(request = RequestMethod.GET)
@RequestMapping(method = RequestMethod.GET)
@RequestMapping(method = RequestMethod.POST)

 

 

What does 'wiring' the beans do?

Uses beans from an XML file.
Sends list parameters.
Sends parameters to constructor of bean.
Creates a referral to other beans.

 

 

What is the role of the @PostConstruct and @PreDestroy annotations?

They are enterprise level constructors
You force in GC when something happens
None of these
Similar to init and destroy method

 

 

How do you load values from property files?

${parameter_name}
<%parameter_name%>
$(parameter_name)
<%=parameter_name%>

 

 

In Spring, singleton means only one instance per _____.

Context
Entire jvm

 

 

Which annotation lets you grab the value of an HTTP request header?

@RequestHeader
@HttpHeader
@Header

 

 

Which of the following is NOT an Autowire type?

byselector
Constructor
autodetect
byType
byName

 

 

What is one of the major improvements in Spring 3?

more annotations are supported
additional lifecycle methods were added
more bean scopes are supported

 

 

Which of the following is NOT a way that weaving can be used?

runtime
class-load time
compile-time
web service

 

 

Which one of the following annotation can be used to inject dependencies a) @Inject b) @Entity c) @Valid d) @Autowire

@Inject and @Autowire
@Inject, @Valid, and @Entity
@Inject, @Valid, and @Autowire
@Inject, and @Valid

 

 

Which of the following concrete implementation, by default, handles the request 'first' when it is sent to a Spring MVC Framework?

DispatcherServlet
FrameworkServlet
GenericServlet
HttpServlet

 

 

What is the @PersistenceContext annotation used for?

injecting a JPA entity manager
injecting a Spring application context used by the ORM framework
Hibernate configuration

 

 

What's the relationship between Spring and Maven?

they are tightly integrated for easy of use
not much; they can be used independently and one does not require the other

 

 

How could you inject using a factory method ?

All of these
Instance (non-static) factory method: specify "factory-bean" and "factory-method" attributes
Static factory method: specify "class" and "factory-method" attributes
Use <constructor-arg> to pass parameters

 

 

Which of the following is a synonym for dependency injection?

aspect-oriented programming
inversion of control
templates
pointcut

 

 

Which of the following is NOT a JDBC statement?

Callable Statement
Regular Statement
Interim Statement
Prepared Statement

 

 

True or False? Using Spring's JDBC support forces you to use Oracle.

False
TRUE

 

 

Which is the most popular way of interfacing with Spring's JDBC support?

SQLStatementPreparerer
JDBCTemplate
transactions
pointcuts

 

 

which one of the following is the correct sequence of how a normal view request is handled in a web application using Spring MVC: 1. Request: A request is submitted to the server. 2. Invokes: The dispatcher dispatches the request to the appropriate controller based on the HTTP request information and the web application configuration. 3. Service Call: The controller interacts with the service layer. 4. Response: The controller updates the model and, based on the execution result, returns the corresponding view to the user.

1234
1423
1324
1432

 

 

What is the name of the central servlet which is part of Spring?

SpringServlet
IoCServlet
DispatcherServlet
WebServlet

 

 

Which of the following statements is correct about Spring MVC:

The DispatcherServlet is the central servlet that receives requests and dispatches them to the appropriate controllers
To enable Spring MVC, the DispatcherServlet needs to be configured in the web.xml
All of these
There can be more than one of DispatcherServlets in a Spring MVC application

 

 

In the following code: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="helloWorld" class="com.tutorialspoint.HelloWorld"> <property name="message" value="Hello World!"/> </bean> </beans> The HelloWorld class should have a method called what?

setName(String message)
setValue(String message)
setMessage(String message)
setProperty(String message)

 

 

True or False? Spring Web MVC supports different locales out of the box.

True
FALSE

 

 

What are the most used classes in Spring DAO?

SimpleJdbcInsert and SimpleJdbcProcedure.
JdbcTemplate and SimpleJdbcTemplate.
SimpleJdbcQuery and SimpleJdbcExec.
SimpleJdbcInsert and SimpleJdbcStoredProc.

 

 

Is the following valid ? - <map><entry key="a" value="b" /></map>

No
Yes

 

 

@RequestMapping is part of which part of Spring?

Web
Security
DAO
Web MVC

 

 

True or False? @RequestMapping can be used on an entire class as well as on individual methods.

FALSE
True

 

 

Does Spring support injection of Enum types?

NO
YES

 

 

What type of dependency injection does Spring NOT support?

Setter injection
Constructor injection
Interface injection

 

 

In AOP, what are the different points where weaving can be applied?

Load time
Compile time
Run time
All of these

 

 

Is it possible to set up Spring AOP using XML configuration only (as opposed to annotations)?

No
Yes

 

 

Configuration to declare a JTA transaction manager “<bean id="mgr" class="org.springframework.transaction.jta.JtaTransactionManager" />“ Is this correct?

Yes
No

 

 

True or False - @Inject is part of Spring Framework

False
True

 

 

Which of the following is NOT a valid spring Application Context implementation?

ConfigurableApplicationContext
ClassPathXmlApplicationContext
XmlWebApplicationContext
FileSystemXmlApplicationContext

 

 

Which one of the following is NOT true about Global Transactions?

In Java, JTA is the standard for implementing global transactions
One of global transaction characteristics is to maintain atomicity, which means either all or none of the involved resources are updated.
In Java JTA is the only way to implement global transaction.
Global transactions are transactions that span multiple backend resources.

 

 

Which one of the following statements is NOT true about Validation API?

In Spring MVC web application context configuration <tx:annotation-driven/> will configure Spring to automatically enable the JSR-303 Bean Validation in Spring.
JSR-303 is a JEE standard and is broadly supported by many frontend/backend frameworks
JSR-303 provides a standard validation API that hides the underlying provider
In Spring MVC web controller, you can annotate the argument in a method with the @Valid annotation.

 

 

Which Spring MVC annotation is NOT valid for use in a method?

@ResponseBody
@RequestParameter
@RequestParam
@RequestMapping

 

 

Which one of the following statements is true:

@Conroller annotation can be used on both class and method
@RequestMapping can only be used on method
@RequestParam annotation helps assigning the request parameter value to the method parameter.
The default value for the method attribute of @RequestMapping is POST

 

 

Which one of the following is not TRUE about Spring MVC and Ajax

The controller handles the request and the response data will be formatted and sent to browser.
In a Ajax call, a XMLHttpRequest is prepared and submitted to the server.
@ResponseBody annotation instruct spring to serialize the returned object to a specific format.
In order for view to be updated properly.The format of the data has to be in JSON

 

 

What will happen if you annotate a setter method with @Required without wiring a bean?

An exception is launched
The required bean is set to null
Spring will create the bean for you
Nothing happens

 

 

If a Spring bean implements BeanNameAware, which method is called with the bean id?

setBeanName()
setBean()
setName()
setId()

 

 

Which of the following is the right way to pass part of URL(user) as input to the request handler method?

@RequestMapping("display/{user}") public String removeMember(@PathVariable("user") String user) {}
@RequestMapping("display/{user}") public String removeMember(@RequestParam("user") String user) {}
@RequestMapping(value ="display/user") public String removeMember(@PathVariable("user") String user) {}

 

 

Which one of the following statements is NOT true about transactions?

Declarative transaction management is achieved by separating transaction management code from your business methods via declarations.
Transaction management, as a kind of crosscutting concern, can be modularized with the AOP approach.
When managing transactions declaratively, you have to include transaction management code in each transactional operation
Programmatic transaction management is achieved by embedding transaction management code in your business methods to control the commit and rollback of transactions.

 

 

Which of these is NOT a valid implementation of ApplicationContext?

BeanFactoryApplicationContext
ClassPathXmlApplicationContext
WebXmlApplicationContext
FileSystemXmlApplicationContext

 

 

Which of the following is a disadvantage of using interfaces for proxies?

cannot use Hibernate
proxy won't be called if one method calls another inside the proxy
generates classes at runtime
it's slower

 

 

Which of the following is NOT a valid advice?

Before throwing advice
After returning advice
Before advice
After throwing advice

 

 

What is the primary use of Inversion of control?

For additional security
All of above
For better memory management
For loose coupling

 

 

Which is NOT a valid form of Advice in AOP?

After throwing advice
After (finally) advice
After returning advice
Before throwing advice
Before advice

 

 

Which of the following Design Patterns is the common solution for the duplicated form submission problem in Spring MVC?

Singleton Pattern
Factory Pattern
Proxy Pattern
Post/Redirect/Get

 

 

What class is used to determine data binding errors, such as those during POST operations?

ParsingResult
BindingResult
BindingErrors
ParsingErrors

 

 

Which one of the following statements is NOT true about the following configuration in security.xml <http ...> … <form-login login-page="/login/form" login-processing-url="/login" username-parameter="username" password-parameter="password" authentication-failure-url="/login/form?error"/> </http>

The password-parameter specifies the HTTP parameters of password that Spring Security will use to authenticate the user.
The authentication-failure-url attribute specifies the page that Spring Security will redirect if Spring cannot find the login page.
The login-page attribute specifies where Spring Security will redirect the browser if a protected page is accessed and the user is not authenticated.
The username-parameter specifies the HTTP parameters of username that Spring Security will use to authenticate the user.

 

 

Which of the following statements is NOT true about the @Autowired annotation?

@Autowired annotation can be applied on more than one properties in the same class
@Autowired annotation can be applied on more than one setter method in the same class
@Autowired annotation was enabled with the <context:annotation-config> element
@Autowired annotation can be applied on more than one constructor method in the same class

 

 

Which of the following object hold the information of principal currently using the application?

InMemoryDaoImpl
SecurityContextLoader
UserDetailsService
SecurityContextHolder

 

 

Which of the following correctly describes TestContextManager of Spring TestContext Framework?

TestContextManager is the main entry point into the Spring TestContext Framework, which is responsible for managing a single TestContext and signaling events to all registered TestExecutionListeners
TestContextManager is the main entry point into the Spring TestContext Framework and is responsible for managing a single TestContext but NOT for signaling events to all registered TestExecutionListeners
TestContextManager is NOT the main entry point into the Spring TestContext Framework, but is responsible for managing a single TestContext and signaling events to all registered TestExecutionListeners
TestContextManager is the main entry point into the Spring TestContext Framework, but is NOT responsible EITHER for managing a single TestContext OR for signaling events to all registered TestExecutionListeners

 

 

How is slf4j commonly used in Spring applications?

as the JDBC provider
as a bean
as the logging framework

 

 

Which of the following is not a valid method to provide configuration metadata to a Spring Container?

Java-based configuration
Annotation-based configuration
XML based configuration file
By marshalling & unmarshalling the objects

 

 

What is MultipartFile used for?

Reading files from disk
Supporting multi-part HTTP requests
That doesn't exist
Saving files to disk

 

 

How many bean configuration files can you have?

as many as you want
two
only one

 

 

What types of transaction management does Spring support?

Declarative transaction management
Programmatic transaction management
Both of these

 

 

What if I need a method to be called after bean construction?

write a custom Handler
delegate to a proxy
use init-method or @PostConstructor

 

 

What are the different modules in Spring framework?

JDBC abstraction and DAO module
Webex module
Hibernate Module

 

 

How are mocks used in Spring?

Spring ignored mocks.
Spring and mocks do not go together well.
They are an important part of using Spring in tests.

 

 

What does a bean definition contain?

How to create a bean
Bean's lifecycle details
All of these
Bean's dependencies

 

 

What is AOP?

Advanced oriented programming
Abstract oriented programming
None of these
Aspect oriented programming

 

 

True or False? Spring supports custom bean scopes.

FALSE
True

 

 

Which is NOT a valid way of injecting a Collection in Spring?

<set>
<collection>
<map>
<list>
<props>

 

 

What is the SpringJUnit4ClassRunner class used for?

Configuring the Maven Surefire plugin
configuring TestNG
Along with @RunWith, starting and stopping a Spring context properly while running JUnit tests

 

 

How can you provide configuration metadata to the Spring container?

All of these
Annotation-based configuration
XML based configuration file
Java-based configuration

 

 

Which of the following is NOT a valid spring framework module?

Spring context
Spring ORM
Spring AOP
Spring Bean Factory

 

 

Can you inject null and empty string values in Spring?

Yes
No

 

 

Which one of the following statements is NOT true about Spring testing annotation?

@ExpectedException: This indicates that test method suppose to throw certain exception
@Repeat(5): This indicates that a test method has to run 5 times.
@IfProfileValue:specifies testing environment of the testing method. Only one environment can be specified
@Timed: This indicates that a test method must complete in a specified time period

 

 

How do you declare a destroy method in a Spring bean?

Referencing as null
None of these
Using the destroy method
We cannot destroy, JVM takes take of it

 

 

Which one of the following statements is NOT true about the Application Context.

ApplicationContext is an interface and is an extension to BeanFactory interface.
When configuring Application Context, Spring supports defining beans either through XML file or annotations starting from Spring 2.5
In a web container environment, Spring bootstraps ApplicatonContext via the ConextLoaderListner.
ApplicationContext provides dependency Injection services and AOP service, but NOT transaction services.

 

 

Which view technologies does Spring Web MVC NOT support out of the box?

Hibernate
XSLT
FreeMarker
Velocity

 

 

What are benefits of transactions for Hibernate?

There are no transactions in Hibernate
None of these
Read only transactions prevent Hibernate from flushing session
Transactions uses less memory and improves performance

 

 

Which of the following is NOT true about Spring transaction management?

The Spring Framework gives you an opportunity to customize transactional behavior, using AOP
The Spring Framework offers declarative rollback rules
The Spring Framework support propagation of transaction contexts across remote calls
The Spring Framework provide a simpler API for programmatic transaction management than a number of complex transaction APIs such as JTA

 

 

What is NOT a way for beans to be defined?

Java
XML configuration file
JSON

 

 

BeanFactory is a popular way to wire beans in Spring, which is a correct way of creating a BeanFactory?

BeanFactory factory = new XmlBeanFactory(new FileInputStream(“beans.xml”));
BeanFactory factory = new BeanFactory(new FileInputStream(“beans.xml”));
BeanFactory factory = new XmlBeanFactory(“classpath:beans.xml”);
BeanFactory factory = new BeanFactory(“beans.xml”);

 

 

Which of the following utility classes provides functionality to set a non-public field or invoke a non-public setter method when testing application code?

TestContextManager
ReflectionTestUtils
SpringJUnit4ClassRunner
TestExecutionListeners

 

 

Which one of the following statements is NOT true about @Transactional attributes

The rollbackFor attribute defines which exception class will cause the transaction to roll back
The timeout attribute defines the number in seconds for transaction time out.
If not specified the default value of propagation attribute is Propagation.REQUIRED
the default value of readOnly attribute is true

 

 

Which of the following identify the application-wide permissions available to a principal?

UserDetailsService
GrantedAuthority
UserDetails
Authentication

 

 

Which one of the following statements is NOT true about the following code: @Service("jpaStudentService") @Repository @Transactional public class StudentServiceImpl implements StudentService { private Log log = LogFactory.getLog(StudentServiceImpl.class); @PersistenceContext private EntityManager em; // Other code omitted }

@PersistenceContext is a Spring annotation which instructs Spring to inject a SessionFactory
@Service is to identify that this class is a spring component providing business services.
@Repository instructs Spring to translate the vendor-specific exceptions to Springs's DataAccessException hierachy.
@Transactional annotations describes transaction attributes of the class.

 

 

If you don't want a method to be enlisted in a transaction at all, what type of attribute can be used?

None of them
@Transactional(readOnly = true)
@Transactional(propagation = Propagation.NEVER)
Both of them

 

 

What is the purpose of the SessionStatus.setComplete()?

Expires the session Data of a controller.
Sets the attribute the session as "complete".
Submits the form input from the user.
Gets the the value of the "complete" attribute of the session.

 

 

What is the @BeforeTransaction annotation used for?

as part of testing, making sure some code is executed before the transaction is started
as part of Spring AOP, defining what to execute before the transaction is started
as part of Spring OXM, what to serialize before the transaction is started

 

 

How do you specify outgoing HTTP content-type?

Use the 'produces' attribute of @RequestMapping
Use the 'contentType' attribute of @RequestMapping
Use the @ContentType annotation

 

 

How do you specify the incoming HTTP content-type?

Use the 'consumes' attribute of @RequestMapping
Use the 'contentType' attribute of @RequestMapping
Use the @ContentType annotation

 

 

A RowCallbackHandler has one method called?

processCallback(ResultSet)
processRow(ResultSet)
processRowCallback(ResultSet)
handleRowCallback(ResultSet)

 

 

Which of the following is incorrect?

BeanFactory does not support enterprise services such JNDI access and EJB integration whereas ApplicationContext facilitates integration with enterprise services
BeanFactory supports just one config file whereas ApplicationContext can have multiple config files
BeanFactory does not support internationalization (I18N) messages whereas ApplicationContext includes support for I18N messages
ApplicationContext does NOT publish events to beans that are registered as listeners whereas BeanFactory published events to registered beans

 

 

Which one of the following statements is NOT true?

Defining Propagation.MANDATORY in @Transactional annotation means there must be a transaction otherwise create one.
<tx:annotation-driven> element is necessary to enable the usage of @Transactional annotations.
The @Transactional annotation can be used on both class level and method level.
When applying transactions semantics, either annotation or pure XML can be used.

 

 

How can we create a PreparedStatementCreator?

createPreparedStatement(Database)
createPreparedStatement()
createPreparedStatement(Connection)
createPreparedStatement(Datasource)

 

 

Which of the following is not a VALID mode of autowiring

byName
byType
autodetect
byClass

 

 

Which of the following are valid approaches for integration Struts with Spring?

Struts - Spring integration is not supported as of Spring 3.x
Any of the given approach can be used to integrate the two
Extending Spring’s ActionSupport classes and getting applications spring-managed beans using getWebApplicationContext() method
Using ContextLoaderPlugin, configuring spring app to manage actions as beans and then setting their dependencies in a spring context file

 

 

Which of the following methods are needed for loading a database driver in JDBC?

registerDriver()
Class.forName()
None of these
Both registerDriver() method and Class.forName()

 

 

Spring - WS Core is NOT dependent on which of the following modules?

Spring OXM
Spring ORM
Spring WS Security
Spring XML

 

 

Which of the following is FIRST step in user authentication process?

The UsernamePasswordAuthenticationToken is passed to an instance of AuthenticationManager for validation
The username and password are obtained and combined into an instance of UsernamePasswordAuthenticationToken
The AuthenticationManager returns a fully populated Authentication instance on successful authentication
The security context is established by calling SecurityContextHolder.getContext().setAuthentication(...), passing in the returned authentication object

 

 

Which of the following best describes the utility of @RunWith(SpringJUnit4ClassRunner.class)?

This annotation means that tests are going to be able to get hold of instantiated beans as defined in the Spring context files
This annotation will inject the SpringJUnit4ClassRunner bean in the test class
This annotation will facilitate the test to get hold of the ApplicationContext
This annotation is indicating the test where to get the context files containing the bean definitions

 

 

Which one of the following statements is NOT true?

SingleConnectionDataSource maintains a single connection that is reused all the time and never closed.
DataSource that looked up by JNDI can be configured in Spring application by using <jee: jndi-lookup> element
It's easy to switch data source implementations in Spring because they implement the common DataSource interface.
The DriverManagerDataSource provided by Spring is a pooled datasource.

 

 

Which of these are types of IOC (dependency injection) ?

None of these
Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided as constructor parameters.
Interface Injection (e.g. Avalon): Injection is done through an interface.
Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods).
All of these

 

 

Which of the following ORM are supported in Spring

All
TopLink
Java Data Objects(JDO)
OJB
iBatis

 

 

Spring Security currently supports authentication integration with which of the following technology

LDAP
Form-based authentication
HTTP Digest authentication headers
All
HTTP BASIC authentication headers

 

 

In transactions and exception management, what is the default rollback policy?

Rollback can happen on any Exception
Rollback for a CompiletimeException
Rollback for a RuntimeException
No Rollbacks possible

 

 

Which one of the following is NOT true about HibernateDaoSupport Class

By extending HibernateDaoSupport class, you can simply call getHibernateTemplate() method to retrieve the template instance.
HibernateDaoSupport class allows you to obtain Session and HibernateTemplate
The common use is to extend this class and inject the SessionFactory dependency
HibernateDaoSupport class, has a commit() method which can commit the transaction


True or False? Spring supports lookup via JNDI.
True
FALSE

 

 

Which one of the following is NOT true about Spring MVC View resolver

TilesViewResolver: Looks up a view that is defined as a Tiles template. The name of the template is the same as the logical view name.
BeanNameViewResolver: Finds an implementation of View that’s registered as a <bean> whose class is the same as the logical view name.
InternalResourceViewResolver: Finds a view template. The path to the view template is derived by prefixing and suffixing the logical view name.
ContentNegotiatingViewResolver: Delegates to one or more other view resolvers, the choice of which is based on the content type being requested.

 

 

Which of the following is true when creating a custom login form for applications using Spring Security?

The name of the username input must corresponds to the values of username-parameter attribute of <form-login> element in security.xml file
The method of the login form must be POST
All of these
The form action url must match the "login-processing-url" attribute of <form-login> element in security.xml file

 

 

Are Spring singleton beans thread-safe?

Depends on how they are setup
No
Yes

 

 

Which of the following statements is NOT true when defining the <intercept-url> elements in security.xml?

The path attribute of the <intercept-url> element is independent and is not aware of the path attribute of the <http> element.
When defining the <intercept-url> elements the sequence doesn't matter
The <intercept-ur> element won't work in the <http> elements that are marked as security = "none".
When using expression based authorization the <http> elements need to be marked as use-expressions="true"

 

 

Which one of the following is NOT true about the followng code: @Controller @RequestMapping("/reservationForm") @SessionAttributes("reservation") public class ReservationFormController { ... @RequestMapping(method = RequestMethod.POST) public String submitForm(@ModelAttribute("reservation") Reservation reservation, BindingResult result) { ... return "redirect:reservationSuccess"; } ... }

The @SessionAttributes is used to save a Reservation object to a user’s session.
The redirect: prefix in the view name is used to avoid a problem known as duplicate form submission.
The BindingResult object is used to map the user request to the controller method.
The @ModelAttribute("reservation") is used to reference the Reservation object.

 

 

Which of the following is a common cross-cutting concern?

configuration
aspects
logging
beans

 

 

Which one of the following statements is true about the propagation attributes that can be defined in @Transactional annotations?

SUPPORTS: If there’s a transaction, it will be supported, if not create a new one
REQUIRES_NEW: Create a new transaction. If there an active transaction exists, throw exception
REQUIRED: If there’s a transaction, support it; otherwise throw exception
MANDATORY: There must be a transaction; otherwise, throw an exception.

 

 

Which of the following annotation enables default data conversion in Spring Web MVC?

@Valid
@InitBinder
@Controller
@RequestMapping

 

 

Which of the following is a VALID Spring form taglib declaration?

<%@ taglib prefix="form" uri="http://www.springframework.com/tags/form" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/form/tags" %>

 

 

<concurrency-control> element can be used for which of the following purposes?

To enable LDAP authentication
To limit number of user sessions
To support concurrent authentication
To support authentication in clustered environment
To support stateless authentication

 

 

What is bean wiring?

connecting the different beans (components) of an application
consuming a web service
avoiding a cross-cutting concern
publishing objects in a web service

 

 

True or False? @PathVariable is used on classes to indicate they will be used as handlers if a variable is found.

False
TRUE

 

 

In Spring and Hibernate integration, which is the correct implementation of the Session Factory?

LocalSessionFactoryBean
SessionFactory
SessionFactoryBean
LocalFactoryBean

 

 

Which of the following best describes Spring Batch?

Spring Batch provides classes and APIs to read/write resources, transaction management, job processing statistics, job restart and partitioning techniques to process high-volume of data
Spring Batch provides classes and APIs for job processing statistics, job restart and partitioning techniques to process high-volume of data and read/write to resources but NOT for transaction management
Spring Batch does NOT provides classes and APIs for job processing statistics, job restart and partitioning techniques but does provide functionality for complex processes like skipping or retrying failed items
Spring Batch provides classes and APIs for job processing statistics, job restart and partitioning techniques to process high-volume of data but NOT for read/write resources and transaction management

 

 

Which one of the following statements is NOT true about Spring Web Flow states?

Action states are where the logic of a flow takes place.
A subflow state starts a new flow within the context of a flow that is already underway.
Decision states branch the flow in two directions, routing the flow based on the outcome of evaluation flow data.
The End state is the last stop. Each flow can only have one end state.

 

 

Which of the following is the most commonly used view resolver for integrating JSPs with Spring?

JstlView
ResourceBundleViewResolver
Both InternalResourceViewResolver and ResourceBundleViewResolver
InternalResourceViewResolver
JSPResourceViewResolver

 

 

Which of the following is NOT an advantage of SimpleJdbcTemplate?

Converts standard JDBC SQLExceptions into checked exceptions
Supports Java 5 features (autoboxing, generics)
Supports operation on stored procedures and batch operations
Uses JDBC API but eliminates lot of problems associated with it

 

 

Which of the following scopes is valid ONLY in the context of a web-aware Spring ApplicationContext?

All of these
response
singleton
global-session
prototype

 

 

Which one of the following statements is NOT true?

<mvc:resources> element helps handling requests for static content for you.
The DispatcherServlet’s job is to send the request on to a Spring MVC controller.
DispatcherServlet could be responsible for all the request by mapping it to "/".
DispatcherServlet can be configured either in web.xml file or through annotation

 

 

What are the features of the XML <context: namespace?

@Transactional annotation scanning
@Aspect annotation detection enabling
@Component annotation scanning and @Transactional annotation scanning
@Autowired annotation enabling and @Component annotation scanning
All of the above

 

 

Which of the following is a valid usage of Method Injection in spring?

Injecting Spring Scoped Proxy Beans
To inject a singleton bean inside an prototype bean
To inject a larger scope bean in a smaller scope bean
To inject a singleton bean inside a non-singleton bean
To inject a non-singleton bean inside a singleton bean

 

 

True or False? Spring provides an abstraction over JMS.

True
FALSE

 

 

Transaction MUST follow which of the following properties?

All of these
Isolation
Atomicity
Consistency

 

 

What is the difference between Bean Factory and Application Context?

Application contexts provide a means for resolving text messages, including support for i18n of those messages.
Application contexts can publish events to beans that are registered as listeners.
Application contexts provide a generic way to load file resources, such as images.
All of these
There is no difference

 

 

Which one of the following statements is NOT true about <mvc: annotation-driven>:

It enables the support of annotation configuration for transactions.
It enables Spring 3 type conversion and formatting support.
It enables Spring's support for JSR-303 Bean Validation.
It enables the support of annotation configuration for Spring MVC controllers.

 

 

Which of the following statements are true about Spring Testing Support?

All of these
The @ContextConfiguration annotation defines the locations of your configuration files
The @Runwith annotation allows you to specify the testing frameworking you would like to use
The TestContext framework of Spring 3 helps simplifying switching between different test framework

 

 

What are the supported scopes in Hibernate?

Web (session, request)
All of these
Prototype
Singleton (default)

 

 

Which of the following implementation provides the mechanism for JSF and Spring integration?

ApplicationContext
ActionSupport
WebApplicationContext
DelegatingVariableResolver
FacesContext

 

 

What is the @WebAppConfiguration annotation used for?

Enable view resolution in Spring Web MVC
Used to configure a Spring web project instead of web.xml
In combination with @ContextConfiguration, used to declare a test as a "web test"

 

 

Spring MVC annotation can be used to perform:

Request mapping
Validation
Request parameter binding
Redirect URL

 

 

Which of the following is a VALID way of implementing Programmatic Transactions in Spring

Using @Transactional annotation
@Controller
Using PlatformTransactionManager
using TransactionInterceptor

 

 

Which of the following development styles are supported by Spring WS?

Contract First but NOT Contract Last
Contract Last but NOT Contract First
Both Contract First and Contract Last
Supports Contract First, Contract Last and Web service contract (WSDL)

 

 

Which of the following is NOT a feature of Spring Security 3.x

Support for limiting number of user sessions
Support for multiple http elements
Support for CAS proxy tickets
Support for stateless authentication

 

 

What are the different points where weaving can be applied?

Classload Time
All of these
Compile Time
Runtime

 

 

Which of the following is NOT a HTTP operation?

MODIFY
GET
POST
PUT

 

 

A SQLProvider has one method called?

getSql()
getProvider()
getSqlProvider()

 

 

Which of the following is NOT a filter type in <context:component-scan> element?

aspectj
assignable
bean
annotation

 

 

How can you find out about the current content when an aspect is invoked?

Through BeanFactory
Through Joinpoint
Through ApplicationContext
Through PointCut

 

 

Which the following statements is true about Spring validation?

@NotNull annotations indicates that the value should not be empty
When using annotation to valid domain object, only one validation annotation is allowed for each property
Custom validation can be implemented through Spring's support of JSR-303, the Bean Validation API
All of these

 

 

Which one of the following statements is NOT true?

If you choose to define your object-to-database mapping by annotation, you’ll need to configure LocalSessionFactoryBean in Spring
The @PersistenceContext annotation is used to tell Spring to inject a Hibernate Session factory instance
One of the responsibilities of HibernateTemplate is to manage Hibernate One of the responsibilities of HibernateTemplate is to manage Hibernate Sessions.
The getCurrentSession() method of SessionFactory returns the session of current transaction

 

 

When are proxies generated in the Spring lifecycle?

None of These
Bean Post Processing
Does not happen in springs
Bean Pre Processing

 

 

The transaction attribute supported by Spring includes:

propagation behavior
isolation levels
rollback rules
All of these

 

 

Which of the following are Autowire types?

byname, byType
autodetect
constructor
All of these

 

 

Which one of the following statements is true about the following configuration in web.xml: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/myapplication/*</url-pattern> </filter-mapping>

The <filter-name> value for the DelegatingFilterProxy must be "springSecurityFilterChain".
It configures springSecurityFilterChain to intercepts all the requests.
It doesn't matter if Spring Security to be declared as first <filter-mapping> element.
Spring Security will intercept forwards, includes, or errors.

 

 

When detecting a Device device in a @Controller in Spring MVC, which of these is NOT supported?

device.isMobile()
device.isDesktop()
device.isTablet()
device.isNormal()

 

 

Which of these is correct when creating an ApplicationContext?

ApplicationsContext ctx = new ClasspathXmlApplicationsContext("one.ctx","two.ctx");
ApplicationContext ctx = new ClasspathXmlApplicationContext("one.ctx”);
None of these
ApplicationContext ctx = new ClasspathXmlApplicationContext("one.ctx","two.ctx");

No comments:

Post a Comment