Sie sind auf Seite 1von 4

Q1.

Spring provide container of type


1. Bean factory
2. Application context
3. Both 1 and 2
4. None of these
Q2. To ask Spring to auto-wire the bean properties with @Autowired or @Resource we can:
1. Register an AutowiredAnnotationBeanPostProcessor
2. Use spring context schema
3. Both approaches is valid eith use spring context schema or register an
AutowiredAnnotationBeanPostProcessor
4. False
Q3. @Autowired annotation can be applied to
1. Field
2. Constructor
3. Setters
4. All of the above
5. Only 2 and 3
Q4. Creates a new bean instance each time when requested
1. Singleton
2. Prototype
3. Request
4. Session
Q5. Maps request to controller and control- ler methods that are annotated with @RequestMapping.
1. BeanNameUrlHandlerMapping
2. ontrollerBeanNameHandlerMapping
3. DefaultAnnotationHandlerMapping
4. None of these
Q6. __________________is a servlet listener that loads additional configuration into a Spring application context
alongside the application context created by DispatcherServlet
1. ContextLoaderListener
2. ServletContextLoaderListner
3. Both 1 and 2 can be configured
4. None of these
Q7. In an project team required capability so that Application contexts can publish events to beans that are registered
as listeners, we can use
1. Applcation context
2. Bean factory
3. Both 1 and 2 can be used
4. None of these

Q8. What are the right affirmations about the @PostConstruct, @Resource and the @PreDestroy
annotations?
1. Those annotations are specified in the JSR-250
2. The Spring Framework embedded those annotation
3. The <context:annotation-config/>tag enable them
4. All are correct

Q9. Select one or many correct answers about spring bean life cycle.
1. The method annoted with @PostConstruct is called after bean instantiation and before
properties setting of the bean
2. The method @PreDestroy of a prototype bean is called when the bean is garbage collected
3. The init() method declared in the init-method attribute of a bean is called before the
afterPropertiesSet callback method of the InitializingBean interface
4. The method annotated with @PostConstruct is called before the afterPropertiesSet
callback method of the InitializingBean interface

Q10. What is/are typically case(s) where you usually need to manually instanciated an ApplicationContext?
1. In a web application
2. In an integration test running with the SpringJUnit4ClassRunner
3. In a standalone application started with a main method
4. None of the above

Q11.In Spring MVC We need to write


1. Front controllers
2. Back controllers
3. Both 1 and 2
4. None of these

Q12 BeanFactory instantiates beans lazily i.e. Beans are instantiated when you get them from BeanFactory not on
loading BeanFactory.
1. True
2. False
Q13. Spring framework support:
1. Constructor injection
2. Setter injection
3. Interface injection
4. All of these
Q14. Default bean scope in spring freamework
1. singleton
2. prototype
3. request
4. session

Q15. Consider
@Controller
public final class RosterController {
private List<Member> members = new ArrayList<Member>();
@RequestMapping
public void list(Model model) {
model.addAttribute(members);// 1
}}

1. it is error as no key is provided while putting value members into model map
2. it will compile with will give error at run time
3. we don’t required to put key into model map, it is gussed to memberList
4. none of these

Q16.
Consider
@Controller
public final class RosterController {
private List<Member> members = new ArrayList<Member>();
@RequestMapping
public void list(Model model) { //1
model.addAttribute(members);
}}

1. error at 1 as no view name is provided with method list(Model model)


2. No need to provide as it is gussed to list.jsp (same as method name)

Q17. What is not the type of auto wiring

1. byName

2. byType

3. constructor

4. All are correct type of autowiring

Q18.______________ Marker superinterface indicating that a bean is eligible to be notified by the Spring container of
a particular framework object through a callback-style method.
1. Aware interface
2. AbstractAware interface
3. BeanNameAware
4. BeanFactoryAware

Q19. What is the best approach for applying bean life cycle methods (We want to insulate from spring framework in
our code)
1. Use aInitializingBean, DisposableBean
2. Use @PreConstruct and @PostConstruct method
3. Using < beaan …..init-method="myInit" destroy-method="cleanUp"/>
4. None of these
Q20. Consider following code snipshot
<bean id="t1" class="com.ex7.Traveler">
<property name="travelerName" value="#{'raj'}"/>
<property name="vehical" ref="#{v}"/>

</bean>
<bean id="v" class="com.ex7.Car"/>

1. It is correct way to refer bean using expression


2. It is not the correct way refer bean using expression

Q21. What is true about Spring transactions read only setting:


1. The read only attribute specifies that the transaction is only going to read data from a database
2. The advantage of read only setting is that the database may apply certain optimization to the transaction when it is
declared to be read only
3. Since read only attribute comes in action as soon as the transaction starts, it may be applied to only those propagation
settings that start a transaction i.e. PROPAGATION_REQUIRED,PROPAGATION_REQUIRES_NEW and
PROPAGATION_NESTED
4. All are true

Q22. How to reload my changes on Spring Boot without having to restart server?
1. put spring jpa dependencies
2. put spring monitoring dependencies
3. put spring Actuator dependencies
4. put spring devTools dependencies

Q23. Servlet filter registered in web deployment descriptor, which filters request in spring application context.
a) DelegatingFilter
b) DelegatingFilterProxy
c) DelegatingProxy
d) None of the mentioned
Q24. Filter chain configured by Spring security, when web app security enabled.
a) springSecurityFilterChain
b) delegatingFilterProxy
c) none of the mentioned
d) all of the mentioned

Q25. Class which declares a number of overloaded update() template methods to control the overall update process.
a) org.springframework.jdbc.core.JdbcTemplate
b) org.springframework.jdbc.core.*
c) org.springframework.jdbc.*
d) none of the mentioned

Das könnte Ihnen auch gefallen