Java interview question 23, java question

Source: Internet
Author: User

Java interview question 23, java question

1. Which of the following statements about the role of Spring MVC's core controller DispatcherServlet is false ()

A. It is responsible for receiving HTTP requests.

B. Load the configuration file.

C. Implement business operations

D. initialize the Application Object ApplicationContext.

Correct answer: C

SpringMVC is a module in Spring. It implements the mvc design mode. First, the user initiates a request to reach SpringMVC's front-end controller (DispatcherServlet ), the front-end controller requests the processor er to find the handle matching the url based on the user's url and returns an execution chain, the front-end Controller then requests the processor adapter to call the corresponding handle for processing and returns a modelAndView to the front-end controller. The front-end Controller then requests the view parser to parse the returned logic view, at last, the front-end controller renders the returned view, loads the data to the request field, and returns it to the user.

As the frontend controller of SpringMVC, DispatcherServlet is responsible for receiving user requests and returning corresponding views to users based on user requests. The c answer is incorrect because the implemented service is on the service layer.

2. Which of the following statements about spring dependency injection is false ()

A. There are two types of dependency injection: Value injection and construction injection:

B. the constructor can determine the injection sequence of the dependency, and the first injection of the Priority dependency.

C. When both the Set-value injection and the set-value injection exist, construct the injection first, and then perform the set-value injection.

D. Set Value injection refers to the IoC container injecting the dependent instance using the setter method of the attribute. This injection method is simple and intuitive.

Correct answer: C

When using constructor dependency injection, Spring ensures that all objects dependent on an object are instantiated before the object is instantiated. When the set method is used for dependency injection, Spring first instantiates the object before instantiating all dependent objects.

When both set-value injection and constructor injection exist, the set-value injection is executed first, and then the constructor injection is executed.

3. Which of the following methods is incorrect When configuring metadata to the Spring container ()

A. Group and Ungroup Objects

B. Basic annotation Configuration

C. Basic Java Configuration

D. Basic XML configuration

Correct answer:

There are three ways to provide metadata to Spring containers: 1. XML configuration file; 2. annotation-based configuration; 3. Java-based configuration. Just remember the concept.

4. Which of the following is NOT a Spring annotation ()

A, @ Aspect

B, @ Service

C, @ Component

D, @ Controller

E, @ View

Correct answer: E

Evaluate the knowledge of spring. Except for the E Option, annotations are commonly used.

5. Which of the following statements about SPRING's transaction propagation feature is false ()

A, PROPAGATION_SUPPORTS: supports the current transaction. If no transaction exists, it is executed in non-transaction mode.

B, PROPAGATION_REQUIRED: supports the current transaction. If no transaction exists, an exception is thrown.

C, PROPAGATION_REQUIRES_NEW: Creates a transaction. If a transaction exists, the current transaction is suspended.

D, PROPAGATION_NESTED: supports the current transaction, adds a Savepoint, and commits or rolls back the transaction in sync with the current transaction.

Correct answer: B

Introduction to propagation attributes of transactions:

PROPAGATION_REQUIRED -- supports the current transaction. If no transaction exists, a new transaction is created. This is the most common choice.

PROPAGATION_SUPPORTS -- supports the current transaction. If no transaction exists, it is executed in non-transaction mode.

PROPAGATION_MANDATORY -- supports the current transaction. If no transaction exists, an exception is thrown.

PROPAGATION_REQUIRES_NEW -- creates a transaction. If a transaction exists, it is suspended.

PROPAGATION_NOT_SUPPORTED -- executes operations in non-transaction mode. If a transaction exists, the current transaction is suspended.

PROPAGATION_NEVER -- runs in non-transaction mode. If a transaction exists, an exception is thrown.

6. Which of the following statements about IoC in Spring is false ()

A. IoC means that the relationship between programs is directly controlled by program code.

B. "control reversal" refers to the transfer of control from application code to external containers.

C. IoC moved the role of control creation into the framework and separated it from the application code.

D. When using the Spring IoC container, you only need to specify the objects required by the component. At runtime, the Spring IoC container will provide them with the XML configuration data.

Correct answer:

IOC, that is, the Inversion of Control (IoC), is an important Object-Oriented Programming Law to reduce the coupling problem of computer programs, it is also the core of the lightweight Spring framework. There are two types of control inversion: Dependency Injection (DI) and Dependency Lookup ).

Join the study exchange group 569772982 to learn and exchange.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.