2018 Latest Java Face Test (technical interview)

Source: Internet
Author: User
Tags aop ticket tomcat server

1. servlet Execution Process

The client issues an HTTP request, the Web server forwards the request to the servlet container, the servlet container resolves the URL and finds the corresponding servlet based on Web. XML, and passes the requests, response objects to the found Servlet, The servlet can know who made the request, request the information, and other information based on request, and when the servlet finishes processing the business logic, it puts the information into the response and responds to the client.

2, SPRINGMVC of the implementation process

SPRINGMVC is a hierarchical control framework that is composed of Dispatchservlet. First the client sends a request Web server to resolve the request URL and goes to match Dispatchservlet's mapping URL, if the match is placed on the Dispatchservlet, Dispatchservlet according to the mapping mapping configuration to find the corresponding Handel, and then give the processing power to find the Handel,handel encapsulated the processing business logic code, When Handel finishes processing, it returns a logical view Modelandview to Dispatchservlet, at which point the Modelandview is a logical view, not a formal view, So Dispatchservlet will parse the Modelandview through the ViewResource view resource, then put the parsed parameters back to the client and show them in the view.

3, given a TXT file, how to get the number of occurrences of a string

File File = new file ("E://test.txt");

InputStream is = new FileInputStream (file);

byte b[] = new byte[1024];

int a = Is.read (b);

String str[] = new String (b,0,a). Split ("");

int count = 0;

for (int i = 0;i<str.length;i++) {

if ("a". Equals (Str[i])) count++;

}

System.out.println (count);

4, Java design mode ideas (single-row mode, Factory mode, strategy mode, a total of 23 design models)

A) Single-case mode: The core of the singleton mode only needs the mode of the new instance object, such as database connection, online number, and so on, some websites see the online population statistics is realized through a singleton mode, put a timer in the database or memory, when someone logged out to add repeatedly put back, Someone quit landing when removed to put back, but when there are two people landing at the same time, will take out the counter at the same time, add one, at the same time put back, so that the data will be wrong, so need a global variable object for all people to use, only need to new an instance object, this is the application of the singleton mode, And the singleton mode saves resources because it controls the number of instance objects and facilitates GC reclamation.

b) Policy mode: It is to extract the public methods of several classes into a new class, which makes the extension easier, ensures the portability of the code, and is highly maintainable. For example, there is a requirement to write a Duck object, ducks have called, fly, shape these three ways, if each duck class write these three methods will appear the code redundancy, this time we can call in ducks, fly, shape these three methods extracted, put in the duck Father class, let each duck inherit this duck Father class, rewrite these three methods, This encapsulation of code portability, when the user proposed new requirements such as duck can swim, then for our OO programmer is very simple we just need to add a swim in the duck parent class, let the swimming ducks rewrite the swimming method can be.

c) Factory mode: The simple Factory mode is to provide a reference to the instance object uniformly, and get the reference of the instance object through the Factory mode interface. For example, a login function, the backend has three classes, controller class, interface class, implement the implementation of the interface class. When the client makes a request, when the request is passed to the Controller class, the controller obtains the reference object of the interface, and the implementation class of the implementing interface encapsulates the business logic code of the login. When you need to add a registration requirement only need to add a registration method in the interface class, implement the implementation method in the class, the controller gets the reference object of the interface, does not need to change the original code, this practice is strong extensibility.

5, bubble sort, two-point search

A) bubbling

public static void MP (int a[]) {

int swap = 0;

for (int i = 0; i < a.length; i++) {

for (int j = i; J < A.length; J + +) {

if (A[j] > A[i]) {

swap = A[i];

A[i] = A[j];

A[J] = swap;

}

}

}

System.out.println (Arrays.tostring (a));

}

b) Two-point lookup public static int ef (int a[], int tag) {

int first = 0;

int end = A.length;

for (int i = 0; i < a.length; i++) {

int middle = (first + end)/2;

if (tag = = A[middle]) {

return middle;

}

if (Tag > A[middle]) {

First = middle + 1;

}

if (Tag < A[middle]) {

end = Middle-1;

}

}

return 0;

}

6, the understanding of Ajax

A) Ajax is an asynchronous request, that is, the local refresh technology, in the traditional page, the user needs to click the button or event trigger request, to refresh the page, and asynchronous technology to trigger the event without a click, so that the user experience is enhanced, such as the mall shopping cart asynchronous loading, When you click on the product, you do not need to request the background and directly modify the parameters.

9. Order of calls between parent and subclass (print result)

A) parent class static code block

b) Sub-class static code block

c) Parent class construction method

D) Sub-class construction method

e) Generic method of sub-class

f) Override the method of the parent class, then print the overridden method

10. Calls to internal classes and external classes

A) an inner class can call directly an external class that includes a private member variable, using an external class that references the this. Keyword call to

b) While an external class calls an inner class to create an inner class object

11. Multithreading

A) a process is a separate operating environment, can be seen as a program, and threads can be regarded as a process of a task, such as QQ is a process, and a QQ window is a thread.

b) in multi-threaded programs, multithreading concurrency can improve the efficiency of the program, the CPU will not because a thread waits for resources to enter the idle state, it will give the resources to other threads.

c) The user thread is the thread that we are developing to create, and the daemon thread is a system thread, such as a GC in a JVM virtual

D) The priority level of the thread: each thread has a priority level, and a limited-level high can get the CPU resources to move the thread from the ready state to the running state first. You can also customize the thread's limited level

E) Deadlock: At least two threads for more than two CPU resources, avoid deadlocks to avoid using nested locks, only need to lock and avoid infinite wait where they want to sync

12. The concept of AOP and IOC (that is, the core of spring)

A) ioc:spring is an open source framework that allows us to reduce workload, improve productivity, and it is a hierarchical structure that corresponds to the corresponding layer processing business logic, reducing the coupling of the code. The core of spring is the IOC control inversion and AOP oriented tangent programming. The main emphasis of the IOC control inversion is that the relationship between the programs is controlled by the container, the container control object, and the acquisition of the external resources is controlled. Inversion is, in traditional programming, we create objects to obtain dependent objects, and in the IOC is a container to help us create objects and inject dependent objects, it is the container to help us find and inject objects, objects are obtained, so called inversion.

b) AOP: Aspect-oriented programming, mainly the management of the system layer of business, such as logs, permissions, things and so on. AOP is to cut open the encapsulated object, identify the common behavior which affects multiple objects, and encapsulate it as a reusable module, which is named as a tangent plane (aspect), which is extracted and encapsulated by logic that is not related to the business logic but is invoked by the business module. It reduces the duplicated code in the system, reduces the coupling between modules, and improves the maintainability of the system.

13, Hibernate's core thought

A) The core idea of Hibernate is ROM object Relationship mapping mechanism. It is the operation between the table and the tables that maps the actions between the objects and the objects. That is, the information extracted from the database is automatically encapsulated into a specific object according to the mapping requirements you set. So hibernate is the modification of the data rows by mapping the data table entity class to the object.

14. The difference between Struts1 and Struts2

15. Optimal deletion of a character of a string

16. The difference between ArrayList and LinkedList

A) is a list interface implementation, ArrayList is an array-based data structure, LinkedList is based on the data structure of the linked list, when the acquisition of specific elements, ArrayList efficiency is relatively fast, it is obtained by the array subscript, The LinkedList needs to move the pointer. When storing elements and deleting elements, LinkedList is more efficient, just move the pointer to the specified position to add or delete, and ArrayList need to move the data.

17. The difference between mybaties and ibatise

18. Database Optimization

A) Select the appropriate field, such as the mailbox field can be set to char (6), as far as possible to set the field as Notnull, so that the database does not need to compare null values when querying

b) query with correlation query (left join on) instead of subquery

c) Create temporary tables manually using union union queries

d) Open things, when the database executes multiple statements error, things will roll back, can maintain the integrity of the database

e) Using foreign keys, things can maintain the integrity of the data, but it does not guarantee the relevance of data, using foreign keys to ensure the relevance of data

f) Using indexes, an index is a common way to improve database performance by enabling the database server to retrieve specific rows at a much faster rate than without indexes, especially when max,min,order by queries.

g) Optimized query statements, in the vast majority of cases, the use of indexes can improve the speed of queries, but if the SQL statement is not used properly, the index does not play its characteristics.

19. Tomcat Server Optimization (memory, number of concurrent connections, cache)

A) memory optimization: Mainly to optimize the Tomcat boot parameters, we can modify its maximum memory number in the Tomcat startup script, and so on.

b) Number of threads optimized: Tomcat's concurrent connection parameters, mainly configured in the Tomcat configuration file server.xml, such as modifying the minimum number of idle connection threads, to improve system processing performance, and so on.

c) Optimize the cache: Open the compression function, modify parameters, such as compressed output content of the default size of 2KB, can be appropriately modified.

20. HTTP protocol

A) Common request methods are get, post

b) Get and post differences: transfer data, get carry parameters and access address transmission, the user can see, this information will be unsafe, resulting in information disclosure. The post then encapsulates the field with the corresponding value in the entity, which is not visible to the user. Get pass parameters are limited, and post is unrestricted.

21. TCP/UDP Agreement

22. What are the basic interfaces of the Java Collection Class framework?

A) Collection collection interface, list, set implementation collection interface, ArrayList, Linkedlist,vector implementation List interface, stack inherits Vector,map interface, Hashtable, HashMap Implementing the Map interface

23. Class Loading Process

A) when encountering a new class, first go to the method area to find the class file, if not found will go to the hard disk to find a class file, found will return, the class file loaded into the method area, when the class loaded, static member variables are assigned to the static area of the method area, A non-static member variable is assigned to a non-static zone, and then starts to initialize the static member variable, assigns the default value, assigns the default value, assigns the value according to the position written by the static member variable, and then executes the static code. When all static code finishes executing, class loading is completed.

24. Creation of objects

A) When a new class is encountered, the class is loaded and positioned to the class file

b) Initialization of all static member variables, static code blocks are executed, and only once when the class is loaded

c) New object, the JVM allocates a large enough storage space in the heap

d) Empty the storage space, assigning default values to all variables, and assigning NULL to all object references

e) Some initialization of the field according to the location of the writing

f) Call constructor method (no inheritance)

25. Optimization of JVM

A) Set the parameters to set the maximum amount of memory for the JVM

b) Selection of the garbage collector

26, High concurrency processing

A) to understand a bit of high concurrency problems, such as a W people rob a ticket, how to ensure that the ticket in the case of not buying everyone can see this ticket, obviously cannot use synchronization mechanism, because synchronize is a lock synchronization can only one person at a time. Lock mechanism can be used at this time, the use of optimistic locking can solve the problem. The simple meaning of optimistic lock is to use the control of business to solve concurrency problem without locking the table, so that the readability of the data is ensured, the data is guaranteed to be exclusive, and the performance of the dirty read data is solved.

27, the understanding of Things

A) things are atomic, consistent, persistent, isolated

b) atomicity: means that in one thing, either all succeeds or all fails to roll back.

c) Consistency: Things are in a consistent state before and after they are executed

D) Persistence: the operation of a thing with multiple data is permanent

E) Isolation: When a thing is working on the data, another thing can not manipulate the data, that is, multiple concurrent things are isolated from each other.

28. Struts Work Flow

A) The client sends a request to the servlet container

b) The request passes through some column filtering by Filterdispatcher call, Filterdispatch through Actionmapper to find the corresponding action.

c) actionmapper find the corresponding action to return to Filterdispatch,dispatch to give the processing right to Actionproxy

D) actionproxy find the corresponding action class through the configuration file

e) Actionproxy Create an instance of Actioniinvocation to process business logic

f) Once the action has been processed, Actioninvocation is responsible for finding the corresponding return result based on the Stuts.xml configuration. The return result is usually a JSP page.

Finally, I wish you all the programmers soon find the right job

To learn a knowledge, first to know why the need, that is, why the problem arises, then to solve, how to use this knowledge.

2018 Latest Java Face Test (technical interview)

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.