Spring Certification Questions: Free On-Line
Spring Certification Questions: Free On-Line
COM Page 1 of 9
Enrol now to get full access to a set of four Spring Mock Exams using our exam
simulator.
QUESTION 1
https://www.springmockexams.com/spring/mock/spring-mock-exam.html
Spring Certification Question: Which of the following is true regarding the @Autowired annotation?
A: It is possible to provide all beans of a particular type from the ApplicationContext by adding the
annotation to a field or method that expects an array of that type.
B: Typed Maps can be autowired as long as the expected key type is String.
C: By default, the autowiring fails whenever zero candidate beans are available.
D: All of the above.
Explanation:
@Autowired
private MovieCatalog[] movieCatalogs;
// ...
}
@Autowired
public void setMovieCatalogs(Map<String, MovieCatalog> movieCatalogs) {
this.movieCatalogs = movieCatalogs;
}
// ...
}
QUESTION 2
A:
<servlet>
<servlet-name>accounts</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/mvc-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
B:
<context-param>
</context-param>
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>jpa</param-value>
</context-param>
C:
<listener>
<listener-class>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/app-config.xml</param-value>
</listener-class>
WWW.SPRINGMOCKEXAMS.COM Page 3 of 9
</listener>
Explanation:
A:The config location defaults can be overridden via the "contextConfigLocation" context-param of
ContextLoader.
B:The config location defaults can be overridden via the servlet init-param of FrameworkServlet.
C:The listener section is used to define a ContextLoaderListener and it does not impact the
application context location.
D:A and B are true.
QUESTION 3
Spring Certification Question: Which are valid method signatures for the method
ClassPathXmlApplicationContext.getBean():
Explanation:
A: Return an instance, which may be shared or independent, of the specified bean name.
B: Behaves the same as getBean(String), but provides a measure of type safety by throwing a
BeanNotOfRequiredTypeException if the bean is not of the required type.
C: This method signature does not exist.
D: Return the bean instance that uniquely matches the given object type, if any.
E: Only A,B,D are true.
QUESTION 4
Spring Certification Question: Which of these is the best description of an AOP Aspect?
Explanation:
QUESTION 5
Spring Certification Question: Which of the following are false regarding Spring AOP?
Explanation:
QUESTION 6
Spring Certification Question: Which of the following is false regarding the following code and
HttpInvokerProxyFactoryBean?
<bean id="httpInvokerProxy"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
WWW.SPRINGMOCKEXAMS.COM Page 5 of 9
<property name="serviceUrl" value="http://remotehost:8080/remoting/AccountService"/>
<property name="serviceInterface" value="example.AccountService"/>
</bean>
Explanation:
By default, the HttpInvokerProxy uses the J2SE HTTP functionality, but you can also use the
Commons HttpClient by setting the httpInvokerRequestExecutor property:
<property name="httpInvokerRequestExecutor">
<bean
class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor"/>
</property>
This is a difficult question but we found something similar on the real exam.
QUESTION 7
Spring Certification Question: Which of the following is true regarding the annotation
@RequestParam in the following piece of code:
@Controller
@RequestMapping("EDIT")
@SessionAttributes("site")
public class PetSitesEditController {
// ...
// ...
}
Explanation:
@Controller
@RequestMapping(value = "/pets/{petId}", method = RequestMethod.GET, produces="application/
json")
@ResponseBody
public Pet getPet(@PathVariable String petId, Model model) {
// implementation omitted
}
E: Only B, C and D are true so this one is false.
QUESTION 8
Spring Certification Question: Which of the following are true regarding the following piece of
code?
<tx:annotation-driven/>
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<jdbc:embedded-database id="dataSource">
<jdbc:script location="classpath:rewards/testdb/schema.sql"/>
<jdbc:script location="classpath:rewards/testdb/test-data.sql"/>
</jdbc:embedded-database>
Explanation:
A: False, it is declaring a local datasource using the tags <jdbc:embedded-database> ... </
jdbc:embedded-database>. The preceding configuration creates an embedded HSQL database
populated with SQL from schema.sql and testdata.sql resources in the classpath. The database
instance is made available to the Spring container as a bean of type javax.sql.DataSource. This
bean can then be injected into data access objects as needed.
B: True. It is a PlatformTransactionManager implementation for a single JDBC DataSource. It binds
a JDBC Connection from the specified DataSource to the current thread, potentially allowing for
one thread-bound Connection per DataSource.
C: True, this is needed for providing Spring transaction support.
D: True. This is the most tricky question because the declaration of the bean post processor it is
hidden in the tag <tx:annotation-driven/>. Remember that you can mark any method with the
@Transactional annotation but the mere presence of the @Transactional annotation is not enough
to activate the transactional behavior. <tx:annotation-driven/> element switches on the
transactional behavior.
E: A is not true so this does not apply.
QUESTION 9
Explanation:
A: Send the given object to the specified destination, converting the object to a JMS message with
a configured MessageConverter.
B: Send the given object to the default destination, converting the object to a JMS message with a
configured MessageConverter.
C: Send the given object to the specified destination, converting the object to a JMS message with
a configured MessageConverter.
WWW.SPRINGMOCKEXAMS.COM Page 8 of 9
D: There is no such method definition. This is a compiler error.
E: Only A,B,C are true.
QUESTION 10
Spring Certification Question: When using JMX which one is false regarding the following piece of
configuration?
<beans>
</beans>
Explanation:
A: This is exactly the aim of the exporter. The bean "testBean" will be exported as an MBean with
name of "testBean1".
B: This is true. The key of each entry in the beans Map is used as the ObjectName for the bean
referenced by the corresponding entry value by default.
C: This is false. Exporter bean must not be lazily initialized if the exporting is to happen. If you
configure a bean with the MBeanExporter that is also configured for lazy initialization, then the
MBeanExporter will not break this contract and will avoid instantiating the bean. Instead, it will
register a proxy with the MBeanServer and will defer obtaining the bean from the container until the
first invocation on the proxy occurs.
D: This is true. The default policy is to expose all properties and all public methods of the bean.
WWW.SPRINGMOCKEXAMS.COM Page 9 of 9
E: False. Only C is false of the above so this is false as well.