Tuesday, December 15, 2015

Spring Framework test answers of 2016.

In this post you can find Complete and recently updated Correct Question and answers of Spring Framework. All Answers updated regularly with new questions. Upwork Spring Framework test answers of 2016.



Question:* Which of these resource prefixes could be used?

Answer: • All of these

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

Answer: • Mock objects

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

Answer: • Yes

Question:* What is the SpringJUnit4ClassRunner class used for?

Answer: • Along with @RunWith, starting and stopping a Spring context properly while running JUnit tests

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

Answer: • use init-method or @PostConstructor

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

Answer: • False

Question:* How is slf4j commonly used in Spring applications?

Answer: • as the logging framework

Question:* What types of transaction management does Spring support?

Answer: • Both of these

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

Answer: • By marshalling & unmarshalling the objects

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

Answer: • All of these

Question:* How many bean configuration files can you have?

Answer: • as many as you want

Question:* What is MultipartFile used for?

Answer: • Supporting multi-part HTTP requests

Question:* Can you inject null and empty string values in Spring?

Answer: • Yes

Question:* What type of dependency injection does Spring NOT support?

Answer: • Interface injection

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

Answer: • Yes

Question:* What is the role of the @PostConstruct and @PreDestroy annotations?

Answer: • Similar to init and destroy method

Question:* True or False? Spring supports custom bean scopes.

Answer: • True

Question:* How are mocks used in Spring?

Answer: • They are an important part of using Spring in tests.

Question:* Does Spring support injection of Enum types?

Answer: • YES

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

Answer: • Yes

Question:* @RequestMapping is part of which part of Spring?

Answer: • Web MVC

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

Answer: • True

Question:* How can you provide configuration metadata to the Spring container?

Answer: • All of these

Question:* What is AOP?

Answer: • Aspect oriented programming

Question:* What is NOT a way for beans to be defined?

Answer: • JSON

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

Answer: • All

Question:* What does a bean definition contain?

Answer: • All of these

Question:* True or False? Spring supports lookup via JNDI.

Answer: • True

Question:* Which of the following ORM are supported in Spring

Answer: • All

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

Answer: • All of these

Question:* Which of these are types of IOC (dependency injection) ?

Answer: • All of these

Question:* True or False? Spring provides an abstraction over JMS.

Answer: • True

Question:* What is bean wiring?

Answer: • connecting the different beans (components) of an application

Question:* Transaction MUST follow which of the following properties?

Answer: • All of these

Question:* What are the supported scopes in Hibernate?

Answer: • All of these

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

Answer: • All of these

Question:* Which of the following is NOT a HTTP operation?

Answer: • MODIFY

Question:* What are the different modules in Spring framework?

Answer: • JDBC abstraction and DAO module

Question:* What are the different points where weaving can be applied?

Answer: • All of these

Question:* The transaction attribute supported by Spring includes:

Answer: • All of these

Question:* What is the difference between Bean Factory and Application Context?

Answer: • All of these

Question:* Which of the following are Autowire types?

Answer: • All of these

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

Answer: • True

Question:* Which of the following is a synonym for dependency injection?

Answer: • inversion of control

Question:* What are the most used classes in Spring DAO?

Answer: • JdbcTemplate and SimpleJdbcTemplate.

Question:* 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?

Answer: • setMessage(String message)

Question:* Which of the following statements is correct about Spring MVC:

Answer: • All of these

Question:* Which of the following is NOT a JDBC statement?

Answer: • Interim Statement

Question:* How could you inject using a factory method ?

Answer: • All of these

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

Answer: • JDBCTemplate

Question:* 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.

Answer: • 1234

Question:* What is the name of the central servlet which is part of Spring?

Answer: • DispatcherServlet

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

Answer: • @RequestHeader

Question:* What's the relationship between Spring and Maven?

Answer: • not much; they can be used independently and one does not require the other

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

Answer: • DispatcherServlet

Question:* What is one of the major improvements in Spring 3?

Answer: • more annotations are supported

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

Answer: • @Inject and @Autowire

Question:* How do you load values from property files?

Answer: • ${parameter_name}

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

Answer: • input will be validated using registered validators for that type

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

Answer: • The controller's main responsibility is to interact with the database like performing CRUD operations.

Question:* What is the default scope of a Spring bean?

Answer: • Singleton

Question:* Which of the following is BAD practice, in general?

Answer: • all beans are prototype scope

Question:* Which is an embedded database supported by Spring?

Answer: • HSQL

Question:* In Spring, singleton means only one instance per _____.

Answer: • Context

Question:* What are the different types of bean injection?

Answer: • By setter, By constructor

Question:* Which of the following best describes @Order annotation?

Answer: • Defines ordering as an alternative to implementing the org. springframework.core.Ordered interface

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

Answer: • instance

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

Answer: • setBeanFactory()

Question:* How does Spring handle XML marshalling/unmarshalling?

Answer: • wraps a variety of libraries, including Jackson and JAXB

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

Answer: • DispatcherServlet

Question:* True or False? Spring supports joda-time.

Answer: • True

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

Answer: • False

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

Answer: • can easily switch between JTA and regular transactions

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

Answer: • DataAccessException

Question:* Which of the following correctly describes JobLauncher?

Answer: • It helps in launching a job and uses JobRepository to obtain a valid JobExecution

Question:* Which of these is NOT a Spring annotation?

Answer: • @View

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

Answer: • SpEL

Question:* What is the @Valid annotation used for?

Answer: • Validating @Controller inputs

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

Answer: • use bean inheritance

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

Answer: • <list> <ref bean="one" /> </list>

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

Answer: • JdbcTemplate template = new JdbcTemplate(myDataSource);

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

Answer: • proxies

Question:* Spring's caching support does what?

Answer: • abstracts a variety of different caching implementations

Question:* Which of these is NOT a Spring Bean Scope?

Answer: • response

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

Answer: • @Componet, @Controller, @Service, and @Repository

Question:* DispatcherServlet class follows which design pattern?

Answer: • FrontController

Question:* What does the ${...} placeholder usually signify?

Answer: • property is read from a configuration file

Question:* Which of the following is NOT an Autowire type?

Answer: • byselector

Question:* Which if the most common scope for DAO beans?

Answer: • singleton

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

Answer: • by property

Question:* What does 'wiring' the beans do?

Answer: • Creates a referral to other beans.

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

Answer: • localSession

Question:* Which of the following statements BEST describes Spring Bean Factory?

Answer: • Spring Bean Factory creates association between collaborating objects as they are instantiated and publish events to beans that are registered as listeners

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

Answer: • @Configuration

Question:* What is JdbcTemplate used for?

Answer: • executing SQL statements against the database

Question:* Which of the following is an INVALID @RequestMapping declaration?

Answer: • @RequestMapping(request = RequestMethod.GET)

Question:* How can you instantiate BeanFactory?

Answer: • Using FileSystemXmlApplicationContext or ClassPathXmlApplicationContext.

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

Answer: • True

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

Answer: • In order for view to be updated properly.The format of the data has to be in JSON

Question:* What is the @PersistenceContext annotation used for?

Answer: • injecting a JPA entity manager

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

Answer: • In Java JTA is the only way to implement global transaction.

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

Answer: • In Spring MVC web application context configuration <tx:annotation-driven/> will configure Spring to automatically enable the JSR-303 Bean Validation in Spring.

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

Answer: • setBeanName()

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

Answer: • web service

Question:* Which one of the following statements is NOT true?

Answer: • @Value annotation can be used on a class

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

Answer: • When managing transactions declaratively, you have to include transaction management code in each transactional operation

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

Answer: • @RequestParameter

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

Answer: • Spring-WS require Spring 2.x or higher

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

Answer: • ConfigurableApplicationContext

Question:* Which is NOT a valid form of Advice in AOP?

Answer: • Before throwing advice

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

Answer: • An exception is launched

Question:* Which one of the following statements is true:

Answer: • @RequestParam annotation helps assigning the request parameter value to the method parameter.

Question:* Which of these is NOT a valid implementation of ApplicationContext?

Answer: • BeanFactoryApplicationContext

Question:* What is the primary use of Inversion of control?

Answer: • For loose coupling

Question:* Which of the following is NOT a valid advice?

Answer: • Before throwing advice

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

Answer: • <collection>

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

Answer: • Post/Redirect/Get

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

Answer: • @RequestMapping("display/{user}") public String removeMember(@PathVariable("user") String user) {}

Question:* Which of the following correctly describes TestContextManager of Spring TestContext Framework?

Answer: • 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

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

Answer: • proxy won't be called if one method calls another inside the proxy

Question:* 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>

Answer: • The authentication-failure-url attribute specifies the page that Spring Security will redirect if Spring cannot find the login page.

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

Answer: • SecurityContextHolder

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

Answer: • @Autowired annotation can be applied on more than one constructor method in the same class

Question:* What are benefits of transactions for Hibernate?

Answer: • Read only transactions prevent Hibernate from flushing session

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

Answer: • BindingResult

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

Answer: • ApplicationContext provides dependency Injection services and AOP service, but NOT transaction services.

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

Answer: • Spring Bean Factory

Question:* How do you declare a destroy method in a Spring bean?

Answer: • Using the destroy method

Question:* A RowCallbackHandler has one method called?

Answer: • processRow(ResultSet)

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

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

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

Answer: • The Spring Framework support propagation of transaction contexts across remote calls

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

Answer: • the default value of readOnly attribute is true

Question:* 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 }

Answer: • @PersistenceContext is a Spring annotation which instructs Spring to inject a SessionFactory

Question:* What is the purpose of the SessionStatus.setComplete()?

Answer: • Expires the session Data of a controller.

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

Answer: • Inject a TaskExecutor and pass it to the Session

Question:* 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?

Answer: • ReflectionTestUtils

Question:* How can we create a PreparedStatementCreator?

Answer: • createPreparedStatement(Connection)

Question:* Which of the following is not a VALID mode of autowiring

Answer: • byClass

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

Answer: • @IfProfileValue:specifies testing environment of the testing method. Only one environment can be specified

Question:* How do you specify outgoing HTTP content-type?

Answer: • Use the 'produces' attribute of @RequestMapping

Question:* How do you specify the incoming HTTP content-type?

Answer: • Use the 'consumes' attribute of @RequestMapping

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

Answer: • Any of the given approach can be used to integrate the two

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

Answer: • @Transactional(propagation = Propagation.NEVER)

Question:* What is the @BeforeTransaction annotation used for?

Answer: • as part of testing, making sure some code is executed before the transaction is started

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

Answer: • Rollback for a RuntimeException

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

Answer: • Both registerDriver() method and Class.forName()

Question:* Which one of the following statements is NOT true?

Answer: • Defining Propagation.MANDATORY in @Transactional annotation means there must be a transaction otherwise create one.

Question:* Which of the following is incorrect?

Answer: • ApplicationContext does NOT publish events to beans that are registered as listeners whereas BeanFactory published events to registered beans

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

Answer: • The username and password are obtained and combined into an instance of UsernamePasswordAuthenticationToken

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

Answer: • Hibernate

Question:* Which one of the following statements is NOT true?

Answer: • The DriverManagerDataSource provided by Spring is a pooled datasource.

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

Answer: • The End state is the last stop. Each flow can only have one end state.

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

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

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

Answer: • Spring WS Security

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

Answer: • GrantedAuthority

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

Answer: • When defining the <intercept-url> elements the sequence doesn't matter

Question:* Which of the following best describes Spring Batch?

Answer: • 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

Question:* Which one of the following is NOT true about HibernateDaoSupport Class

Answer: • HibernateDaoSupport class, has a commit() method which can commit the transaction

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

Answer: • logging

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

Answer: • This annotation means that tests are going to be able to get hold of instantiated beans as defined in the Spring context files

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

Answer: • To limit number of user sessions

Question:* Which one of the following statements is NOT true?

Answer: • DispatcherServlet can be configured either in web.xml file or through annotation

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

Answer: • MANDATORY: There must be a transaction; otherwise, throw an exception.

Question:* Which of the following is NOT an advantage of SimpleJdbcTemplate?

Answer: • Converts standard JDBC SQLExceptions into checked exceptions

Question:* 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"; } ... }

Answer: • The BindingResult object is used to map the user request to the controller method.

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

Answer: • global-session

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

Answer: • To inject a non-singleton bean inside a singleton bean

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

Answer: • @InitBinder

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

Answer: • BeanNameViewResolver: Finds an implementation of View that’s registered as a <bean> whose class is the same as the logical view name.

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

Answer: • Both InternalResourceViewResolver and ResourceBundleViewResolver

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

Answer: • DelegatingVariableResolver

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

Answer: • Using PlatformTransactionManager

Question:* Spring MVC annotation can be used to perform:

Answer: • Redirect URL

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

Answer: • bean

Question:* Are Spring singleton beans thread-safe?

Answer: • No

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

Answer: • False

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

Answer: • It enables the support of annotation configuration for transactions.

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

Answer: • Contract First but NOT Contract Last

Question:* Which one of the following statements is NOT true?

Answer: • If you choose to define your object-to-database mapping by annotation, you’ll need to configure LocalSessionFactoryBean in Spring

Question:* A SQLProvider has one method called?

Answer: • getSql()

Question:* What is the @WebAppConfiguration annotation used for?

Answer: • In combination with @ContextConfiguration, used to declare a test as a "web test"

Question:* Which the following statements is true about Spring validation?

Answer: • Custom validation can be implemented through Spring's support of JSR-303, the Bean Validation API

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

Answer: • LocalSessionFactoryBean

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

Answer: • Support for limiting number of user sessions

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

Answer: • Through Joinpoint

Question:* When are proxies generated in the Spring lifecycle?

Answer: • Bean Post Processing

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

Answer: • device.isDesktop()

Question:* 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>

Answer: • The <filter-name> value for the DelegatingFilterProxy must be "springSecurityFilterChain".

Question:* Which of these is correct when creating an ApplicationContext?

Answer: • ApplicationContext ctx = new ClasspathXmlApplicationContext("one.ctx","two.ctx");

Question:* Which of these resource prefixes could be used?

Answer: • All of these

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

Answer: • Mock objects

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

Answer: • Yes

Question:* What is the SpringJUnit4ClassRunner class used for?

Answer: • Along with @RunWith, starting and stopping a Spring context properly while running JUnit tests

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

Answer: • use init-method or @PostConstructor

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

Answer: • False

Question:* How is slf4j commonly used in Spring applications?

Answer: • as the logging framework

Question:* What types of transaction management does Spring support?

Answer: • Both of these

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

Answer: • By marshalling & unmarshalling the objects

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

Answer: • All of these

Question:* How many bean configuration files can you have?

Answer: • as many as you want

Question:* What is MultipartFile used for?

Answer: • Supporting multi-part HTTP requests

Question:* Can you inject null and empty string values in Spring?

Answer: • Yes

Question:* What type of dependency injection does Spring NOT support?

Answer: • Interface injection

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

Answer: • Yes

Question:* What is the role of the @PostConstruct and @PreDestroy annotations?

Answer: • Similar to init and destroy method

Question:* True or False? Spring supports custom bean scopes.

Answer: • True

Question:* How are mocks used in Spring?

Answer: • They are an important part of using Spring in tests.

Question:* Does Spring support injection of Enum types?

Answer: • YES

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

Answer: • Yes

Question:* @RequestMapping is part of which part of Spring?

Answer: • Web MVC

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

Answer: • True

Question:* How can you provide configuration metadata to the Spring container?

Answer: • All of these

Question:* What is AOP?

Answer: • Aspect oriented programming

Question:* What is NOT a way for beans to be defined?

Answer: • JSON

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

Answer: • All

Question:* What does a bean definition contain?

Answer: • All of these

Question:* True or False? Spring supports lookup via JNDI.

Answer: • True

Question:* Which of the following ORM are supported in Spring

Answer: • All

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

Answer: • All of these

Question:* Which of these are types of IOC (dependency injection) ?

Answer: • All of these

Question:* True or False? Spring provides an abstraction over JMS.

Answer: • True

Question:* What is bean wiring?

Answer: • connecting the different beans (components) of an application

Question:* Transaction MUST follow which of the following properties?

Answer: • All of these

Question:* What are the supported scopes in Hibernate?

Answer: • All of these

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

Answer: • All of these

Question:* Which of the following is NOT a HTTP operation?

Answer: • MODIFY

Question:* What are the different modules in Spring framework?

Answer: • JDBC abstraction and DAO module

Question:* What are the different points where weaving can be applied?

Answer: • All of these

Question:* The transaction attribute supported by Spring includes:

Answer: • All of these

Question:* What is the difference between Bean Factory and Application Context?

Answer: • All of these

Question:* Which of the following are Autowire types?

Answer: • All of these

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

Answer: • True

Question:* Which of the following is a synonym for dependency injection?

Answer: • inversion of control

Question:* What are the most used classes in Spring DAO?

Answer: • JdbcTemplate and SimpleJdbcTemplate.

Question:* 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?

Answer: • setMessage(String message)

Question:* Which of the following statements is correct about Spring MVC:

Answer: • All of these

Question:* Which of the following is NOT a JDBC statement?

Answer: • Interim Statement

Question:* How could you inject using a factory method ?

Answer: • All of these

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

Answer: • JDBCTemplate

Question:* 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.

Answer: • 1234

Question:* What is the name of the central servlet which is part of Spring?

Answer: • DispatcherServlet

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

Answer: • @RequestHeader

Question:* What's the relationship between Spring and Maven?

Answer: • not much; they can be used independently and one does not require the other

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

Answer: • DispatcherServlet

Question:* What is one of the major improvements in Spring 3?

Answer: • more annotations are supported

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

Answer: • @Inject and @Autowire

Question:* How do you load values from property files?

Answer: • ${parameter_name}

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

Answer: • input will be validated using registered validators for that type

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

Answer: • The controller's main responsibility is to interact with the database like performing CRUD operations.

Question:* What is the default scope of a Spring bean?

Answer: • Singleton

Question:* Which of the following is BAD practice, in general?

Answer: • all beans are prototype scope

Question:* Which is an embedded database supported by Spring?

Answer: • HSQL

Question:* In Spring, singleton means only one instance per _____.

Answer: • Context

Question:* What are the different types of bean injection?

Answer: • By setter, By constructor

Question:* Which of the following best describes @Order annotation?

Answer: • Defines ordering as an alternative to implementing the org. springframework.core.Ordered interface

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

Answer: • instance

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

Answer: • setBeanFactory()

Question:* How does Spring handle XML marshalling/unmarshalling?

Answer: • wraps a variety of libraries, including Jackson and JAXB

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

Answer: • DispatcherServlet

Question:* True or False? Spring supports joda-time.

Answer: • True

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

Answer: • False

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

Answer: • can easily switch between JTA and regular transactions

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

Answer: • DataAccessException

Question:* Which of the following correctly describes JobLauncher?

Answer: • It helps in launching a job and uses JobRepository to obtain a valid JobExecution

Question:* Which of these is NOT a Spring annotation?

Answer: • @View

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

Answer: • SpEL

Question:* What is the @Valid annotation used for?

Answer: • Validating @Controller inputs

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

Answer: • use bean inheritance

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

Answer: • <list> <ref bean="one" /> </list>

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

Answer: • JdbcTemplate template = new JdbcTemplate(myDataSource);

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

Answer: • proxies

Question:* Spring's caching support does what?

Answer: • abstracts a variety of different caching implementations

Question:* Which of these is NOT a Spring Bean Scope?

Answer: • response

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

Answer: • @Componet, @Controller, @Service, and @Repository

Question:* DispatcherServlet class follows which design pattern?

Answer: • FrontController

Question:* What does the ${...} placeholder usually signify?

Answer: • property is read from a configuration file

Question:* Which of the following is NOT an Autowire type?

Answer: • byselector

Question:* Which if the most common scope for DAO beans?

Answer: • singleton

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

Answer: • by property

Question:* What does 'wiring' the beans do?

Answer: • Creates a referral to other beans.

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

Answer: • localSession

Question:* Which of the following statements BEST describes Spring Bean Factory?

Answer: • Spring Bean Factory creates association between collaborating objects as they are instantiated and publish events to beans that are registered as listeners

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

Answer: • @Configuration

Question:* What is JdbcTemplate used for?

Answer: • executing SQL statements against the database

Question:* Which of the following is an INVALID @RequestMapping declaration?

Answer: • @RequestMapping(request = RequestMethod.GET)

Question:* How can you instantiate BeanFactory?

Answer: • Using FileSystemXmlApplicationContext or ClassPathXmlApplicationContext.

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

Answer: • True

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

Answer: • In order for view to be updated properly.The format of the data has to be in JSON

Question:* What is the @PersistenceContext annotation used for?

Answer: • injecting a JPA entity manager

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

Answer: • In Java JTA is the only way to implement global transaction.

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

Answer: • In Spring MVC web application context configuration <tx:annotation-driven/> will configure Spring to automatically enable the JSR-303 Bean Validation in Spring.

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

Answer: • setBeanName()

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

Answer: • web service

Question:* Which one of the following statements is NOT true?

Answer: • @Value annotation can be used on a class

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

Answer: • When managing transactions declaratively, you have to include transaction management code in each transactional operation

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

Answer: • @RequestParameter

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

Answer: • Spring-WS require Spring 2.x or higher

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

Answer: • ConfigurableApplicationContext

Question:* Which is NOT a valid form of Advice in AOP?

Answer: • Before throwing advice

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

Answer: • An exception is launched

Question:* Which one of the following statements is true:

Answer: • @RequestParam annotation helps assigning the request parameter value to the method parameter.

Question:* Which of these is NOT a valid implementation of ApplicationContext?

Answer: • BeanFactoryApplicationContext

Question:* What is the primary use of Inversion of control?

Answer: • For loose coupling

Question:* Which of the following is NOT a valid advice?

Answer: • Before throwing advice

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

Answer: • <collection>

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

Answer: • Post/Redirect/Get

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

Answer: • @RequestMapping("display/{user}") public String removeMember(@PathVariable("user") String user) {}

Question:* Which of the following correctly describes TestContextManager of Spring TestContext Framework?

Answer: • 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

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

Answer: • proxy won't be called if one method calls another inside the proxy

Question:* 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>

Answer: • The authentication-failure-url attribute specifies the page that Spring Security will redirect if Spring cannot find the login page.

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

Answer: • SecurityContextHolder

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

Answer: • @Autowired annotation can be applied on more than one constructor method in the same class

Question:* What are benefits of transactions for Hibernate?

Answer: • Read only transactions prevent Hibernate from flushing session

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

Answer: • BindingResult

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

Answer: • ApplicationContext provides dependency Injection services and AOP service, but NOT transaction services.

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

Answer: • Spring Bean Factory

Question:* How do you declare a destroy method in a Spring bean?

Answer: • Using the destroy method

Question:* A RowCallbackHandler has one method called?

Answer: • processRow(ResultSet)

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

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

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

Answer: • The Spring Framework support propagation of transaction contexts across remote calls

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

Answer: • the default value of readOnly attribute is true

Question:* 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 }

Answer: • @PersistenceContext is a Spring annotation which instructs Spring to inject a SessionFactory

Question:* What is the purpose of the SessionStatus.setComplete()?

Answer: • Expires the session Data of a controller.

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

Answer: • Inject a TaskExecutor and pass it to the Session

Question:* 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?

Answer: • ReflectionTestUtils

Question:* How can we create a PreparedStatementCreator?

Answer: • createPreparedStatement(Connection)

Question:* Which of the following is not a VALID mode of autowiring

Answer: • byClass

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

Answer: • @IfProfileValue:specifies testing environment of the testing method. Only one environment can be specified

Question:* How do you specify outgoing HTTP content-type?

Answer: • Use the 'produces' attribute of @RequestMapping

Question:* How do you specify the incoming HTTP content-type?

Answer: • Use the 'consumes' attribute of @RequestMapping

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

Answer: • Any of the given approach can be used to integrate the two

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

Answer: • @Transactional(propagation = Propagation.NEVER)

Question:* What is the @BeforeTransaction annotation used for?

Answer: • as part of testing, making sure some code is executed before the transaction is started

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

Answer: • Rollback for a RuntimeException

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

Answer: • Both registerDriver() method and Class.forName()

Question:* Which one of the following statements is NOT true?

Answer: • Defining Propagation.MANDATORY in @Transactional annotation means there must be a transaction otherwise create one.

Question:* Which of the following is incorrect?

Answer: • ApplicationContext does NOT publish events to beans that are registered as listeners whereas BeanFactory published events to registered beans

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

Answer: • The username and password are obtained and combined into an instance of UsernamePasswordAuthenticationToken

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

Answer: • Hibernate

Question:* Which one of the following statements is NOT true?

Answer: • The DriverManagerDataSource provided by Spring is a pooled datasource.

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

Answer: • The End state is the last stop. Each flow can only have one end state.

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

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

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

Answer: • Spring WS Security

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

Answer: • GrantedAuthority

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

Answer: • When defining the <intercept-url> elements the sequence doesn't matter

Question:* Which of the following best describes Spring Batch?

Answer: • 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

Question:* Which one of the following is NOT true about HibernateDaoSupport Class

Answer: • HibernateDaoSupport class, has a commit() method which can commit the transaction

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

Answer: • logging

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

Answer: • This annotation means that tests are going to be able to get hold of instantiated beans as defined in the Spring context files

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

Answer: • To limit number of user sessions

Question:* Which one of the following statements is NOT true?

Answer: • DispatcherServlet can be configured either in web.xml file or through annotation

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

Answer: • MANDATORY: There must be a transaction; otherwise, throw an exception.

Question:* Which of the following is NOT an advantage of SimpleJdbcTemplate?

Answer: • Converts standard JDBC SQLExceptions into checked exceptions

Question:* 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"; } ... }

Answer: • The BindingResult object is used to map the user request to the controller method.

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

Answer: • global-session

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

Answer: • To inject a non-singleton bean inside a singleton bean

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

Answer: • @InitBinder

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

Answer: • BeanNameViewResolver: Finds an implementation of View that’s registered as a <bean> whose class is the same as the logical view name.

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

Answer: • Both InternalResourceViewResolver and ResourceBundleViewResolver

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

Answer: • DelegatingVariableResolver

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

Answer: • Using PlatformTransactionManager

Question:* Spring MVC annotation can be used to perform:

Answer: • Redirect URL

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

Answer: • bean

Question:* Are Spring singleton beans thread-safe?

Answer: • No

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

Answer: • False

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

Answer: • It enables the support of annotation configuration for transactions.

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

Answer: • Contract First but NOT Contract Last

Question:* Which one of the following statements is NOT true?

Answer: • If you choose to define your object-to-database mapping by annotation, you’ll need to configure LocalSessionFactoryBean in Spring

Question:* A SQLProvider has one method called?

Answer: • getSql()

Question:* What is the @WebAppConfiguration annotation used for?

Answer: • In combination with @ContextConfiguration, used to declare a test as a "web test"

Question:* Which the following statements is true about Spring validation?

Answer: • Custom validation can be implemented through Spring's support of JSR-303, the Bean Validation API

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

Answer: • LocalSessionFactoryBean

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

Answer: • Support for limiting number of user sessions

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

Answer: • Through Joinpoint

Question:* When are proxies generated in the Spring lifecycle?

Answer: • Bean Post Processing

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

Answer: • device.isDesktop()

Question:* 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>

Answer: • The <filter-name> value for the DelegatingFilterProxy must be "springSecurityFilterChain".

Question:* Which of these is correct when creating an ApplicationContext?

Answer: • ApplicationContext ctx = new ClasspathXmlApplicationContext("one.ctx","two.ctx");



No comments:

HTML5 Upwork (oDesk) TEST ANSWERS 2022

HTML5 Upwork (oDesk) TEST ANSWERS 2022 Question: Which of the following is the best method to detect HTML5 Canvas support in web br...

Disqus for upwork test answers