Java senior engineer interview questions collection (interview on the three frameworks of Struts, Spring, and Hibernate)

1. How Hibernate works and why is it used?
How it works: 1. Read and parse configuration file 2. Read and parse mapping information, create SessionFactory 3. Open Session 4. Create transaction Transation 5. Persist operation 6. Commit transaction 7. Close Session 8. Close
SessionFactory Use: 1. Encapsulate the JDBC access database code, which greatly simplifies the tedious and repetitive code of the data access layer. 2. Hibernate is a mainstream persistence framework based on JDBC and an excellent ORM implementation. He greatly simplifies the coding work of the DAO layer 3. hibernate uses the Java reflection mechanism instead of the bytecode enhancement program to achieve transparency. 4. The performance of hibernate is very good because it is a lightweight framework. The flexibility of the mapping is excellent. It supports all kinds of relational databases, from one-to-many to many-to-many complex relationships.

2. How does Hibernate lazy load?
1. Hibernate2 lazy loading implementation: a) entity object b) collection (Collection)
2. Hibernate3 provides the lazy loading function of attributes When Hibernate queries data, the data does not exist in memory, when When the program actually operates on the data, the object exists in the memory, and the lazy loading is realized, which saves the memory overhead of the server and improves the performance of the server.

3. How to realize the relationship between classes in Hibernate? (such as: one-to-many, many-to-many relationship) The relationship between
classes is mainly reflected in the relationship between tables and tables, and they all operate on objects. All tables and classes are mapped together in our program, and they pass the many-to-one, one-to-many, and many-to-many configuration files

4.Struts1 process:
1. The client browser sends an HTTP request. 2. According to the web.xml configuration, the request is received by ActionServlet. 3. According to struts-config.xml configuration, ActionServlet first fills the parameters in the request into ActionForm, and then ActionServlet sends the request to Action for processing. 4. Whether to verify, call the validate method of ActionForm if verification is required, jump to the input if the verification fails, and continue if it succeeds. 5. Action obtains data from ActionForm and calls business methods in javabean to process data. 6. Action returns the ActionForward object and jumps to the corresponding JSP page or Action. 7. Return an HTTP response to the client browser.

MVC design pattern: modal: "model", also known as business logic, is the code that actually completes the task, which is equivalent to JavaBeanview: view, which is actually a display interface, equivalent to JSPcontroller: controller, which controls the interaction process between model and view, equivalent to servletstruts1 is based on MVC design pattern hibernate is based on ORM object relational mapping

5.What is struts?
Struts1 is an open source web application framework based on JSP and servlet, using the MVC design pattern struts2 is a framework based on webwork technology, a framework with very complete functions jointly developed by sun and webwork companies, struts2 and struts1 have nothing to do , is a brand new framework

6. What is spring?
Spring is a hodgepodge that integrates many third-party frameworks, and its core technologies are IOC (Inversion of Control, also known as Dependency Injection) and AOP (Aspect-Oriented Programming)

7.What is hibernate?
Hibernate is based on ORM object-relational mapping (a mechanism to complete the mapping of object data to relational data) and is a tool for data persistence

8. What is JSF?
JavaServer Face is a component-based web development framework, similar to sturts

9. What are the indexes and constraints in the database? The
index is to improve the retrieval speed of the data. The index is established on the data table. The constraints established according to one or more fields are to maintain the integrity of the data. The constraints have non-null constraints , primary key constraints, foreign key constraints, and more.

10. What
is spring This question can often be cut through the question of why we use spring: AOP allows developers to create non-behavioral concerns, called cross-cutting concerns, and insert them into application code . With AOP, common services (such as logging, persistence, transactions, etc.) can be decomposed into aspects and applied to domain objects without adding complexity to the object model of the domain objects. IOC allows the creation of an application environment in which objects can be constructed and then passed to those objects their collaborating objects. As the word inversion suggests, IOC is like JNDI in reverse. Instead of using a bunch of abstract factories, service locators, singletons, and straight constructions, each object is constructed with its collaborating objects. So the container manages the collaborator. Even though Spring is an AOP framework, it is also an IOC container. The best thing about Spring is that it helps you replace objects. With Spring, just add dependencies (collaboration objects) with JavaBean properties and configuration files. Collaborating objects with similar interfaces can then be easily replaced when needed.

11. Briefly describe the execution flow of struts2 in your own words.
The Struts 2 framework itself can be roughly divided into three parts: the core controller FilterDispatcher, the business controller Action and the enterprise business logic components implemented by the user. The core controller FilterDispatcher is the basis of the Struts 2 framework, including the control flow and processing mechanism within the framework. The business controller Action and business logic components need to be implemented by the user. While developing Action and business logic components, users also need to write related configuration files for the core controller FilterDispatcher to use.

The workflow of Struts 2 is simpler than that of Struts 1, and it is basically the same as the WebWork framework, so Struts 2 is an upgraded version of WebWork. The basic brief process is as follows: 1. The client browser sends an HTTP request. 2. According to the web.xml configuration, the request is received by FilterDispatcher. 3. According to the struts.xml configuration, find the Action class and method to be called, and inject the value into Aciton through the IoC method. 4. Action calls the business logic component to process business logic. This step includes form validation. 5. After the Action is executed, find the corresponding return result according to the configuration in struts.xml, and jump to the corresponding page. 6. Return an HTTP response to the client browser.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325860840&siteId=291194637