1. (Single choice) What is wrong with the IOC description of Spring features?

A. OC means that the relationship between programs is directly controlled by program code. B. “inversion of control” refers to the transfer of control from application code to an external container. The transfer of control c. IOC moves the responsibility for control creation into the framework; D. When using Spring’s IOC container, simply point out the objects the component needs, which Spring’s IOC container provides to it at run time based on XML configuration data.

A) IOC B) inversion C) inversion D) inversion

2. (Single choice) The composition of Spring consists of () blocks

A.1 b. 3 c. 5 d. 7 【答案 】D Core Spring AOP Spring ORM Spring DAO Spring WEB Spring Context Spring MVC

3. (single choice) What is wrong with spring?

A.Spring supports pluggable transaction managers to make transaction partitioning easier without dealing with underlying issues. B.Spring’s common abstraction layer for transaction management also includes JTA policies and a JDBC DataSource. C.Spring’s transaction support is dependent on the Java EE environment. D.Spring transaction semantics are applied to POJOs via AOP and configured via XML or Java SE 5 annotations. Spring’s transaction support does not depend on the Java EE environment

4. (Multiple choice) How many ways to inject IOC ()

A. constructor injection B. attribute injection C. interface injection D. none of the above.

5. (Multiple choice) What is true about the following configuration?

<bean id="eb1" class="ioc.ExampleBean" 
		init-method="init"
Copy the code

Destroy-method = “destroy” lazy-init= “true” > a.init-method Specifies the initialization method. B.destroy-method Specifies the destruction method. C. The name of the initialization method in all beans must be init. D. lasy-init If true, delayed instantiation. B) how does the container manage the bean life cycle? C) there are no specific requirements for the naming of initialization and destruction methods.

6. (Multiple choice) The following configuration is correct.

<bean id="bar1" class="ioc.autowire.Bar" autowire="byName"/>
Copy the code

A. The container will adopt auto-assembly to establish dependencies. B. ByName specifies to find the bean with the same property name and call the set method to complete the injection. C. Byname may find multiple beans that match the conditions, causing an error. D.autowire can also be byType and constructor. If the value is byName, the container will look for the bean with the same attribute name and call the corresponding set method to complete the injection. Because bar1 is the bean ID in this case and is therefore unique, it is impossible to find more than one bean that matches the requirement.

7. (Multiple choice) The following configuration is correct.

<util:properties id="config" location="classpath:config.properties"/>
<bean id="db" class="ioc.common.DemoBean">
		<property name="brand" value="#{mp.brand}"/>
		<property name="interest" value="#{user.interest[1]}"/>
		<property name="city" value="#{user.cities[1]}"/>
		<property name="score" value="#{user.scores.english}"/>
		<property name="pwd" value="#{user.info.pwd}"/>
		<property name="pagesize" value="#{config.pagesize}"/>
		<property name="type" value=""/>
</bean>
Copy the code

The syntax of a. spring expressions is very similar to el expressions. B. Spring expressions can read data from beans or collections. C.#{user.interest[1]} reads the inerest property of the bean whose id is user. The value of this property is a set of lists in which 1 represents the subscript. D.value=” “is wrong. A. value= “”; value=” “; value= “”;

8. (MULTIPLE choice) What is true about the Spring container? In Spring, any Java class and JavaBean can be treated as beans, which are managed and used by the container. The B.Spring container implements IOC and AOP mechanisms that simplify Bean object creation and decoupling between Bean objects. C.Spring container provides the environment needed to run servlets. D. spring containers have types such as BeanFactory and ApplicationContext. A) Spring B) Spring C) Spring D) Spring Running servlets requires a container that complies with the Servlet specification, such as Tomcat. The Spring container is a core component of the Spring framework. The other options describe some aspects of the Spring container and are therefore correct.

9. (Multiple choice) The following configuration is correct.

<bean id="mp" class="ioc.set.MobilePhone">
		<property name="brand" value="Huawei mate8"/>
		<property name="cpu" value="Kylin"/>
		<property name="ram" value="2G"/>
</bean>
Copy the code

A. Set injection is used. B. Constructor injection is adopted here. C. Mobilephone classes must have setBrand methods. D. Mobilephone class must have brand geners. The spring container calls the setBrand method, but it does not declare that the MobilePhone class must have A brand attribute. The above configuration is not a constructor injection mode.

Spring is a heavyweight framework.Spring is a lightweight framework.Spring is a container containing IOC and AOP features.Spring is an intrusive framework Spring is a lightweight framework. The two main modules are Spring IOC and Spring AOP

11. (MULTIPLE choice) What is true about IOC? A. Spring IOP B. Spring IOP C. Spring IOP D. Spring IOP

12. (MULTIPLE choice) The following statements about Spring are true. A.Spring is an open source lightweight application development framework. B.Spring provides an overall solution for the system. C.Spring is a development language. D.Spring provides IOC and AOP capabilities to minimize component coupling, or decoupling, for future system maintenance and upgrades. A) Spring B) Spring C) Spring D) Spring Spring is an application development framework, not a programming language, so C is wrong. The other options describe the benefits of the Spring framework from different perspectives and are all correct.

13. (Multiple choice) What is true about the bean life cycle ()? A. Each bean must provide A corresponding lifecycle method. B. The destruction method applies only to singleton beans. C. The destruction method can be run multiple times. D. The initialization method is executed only once. B) how does the container manage the bean life cycle? When designing the bean, according to the actual business needs, you can provide the bean with the corresponding life-cycle methods, such as the initialization method to complete the resource loading and similar logic, and the release of resources in the destruction method. Therefore, whether there are lifecycle related methods in the bean depends on the actual business needs and is not required. C) The destruction method is used to release resources and only needs to be executed once.