Java Senior Engineer interview questions and suggested answers are summarized

First, the face questions summing up

1, the principle JVM structure, GC mechanism Detailed
A: The specific reference: JVM structure, GC Detailed working mechanism, when it comes to GC, remember two things: 1, GC is responsible for recycling all without any reference to the object memory space. Note: garbage collection is recovered without any memory space occupied by the object reference instead of the object itself, 2, two algorithms GC collection mechanism, a, reference notation B, reachability analysis algorithm (here reachability, we can see what a periodic basis 2 Java objects), as more detailed GC algorithm description, we can refer to: Java GC mechanism algorithm
2, the life cycle of Java objects
a: the creation phase, application phase, invisible stage, unreachable stage , collection phase, the end stage, the object space reallocation stage, etc., with specific reference to: the life cycle of Java objects
3, Map or storage principle of HashMap
a: HashMap is composed of an array of linked list structure consisting of a +, with specific reference to: realization of HashMap principle
4, when the data in table a, B field made composite index, use a alone or B alone it will have the effect of index? (Query like how to use the index effect)
Answer: see A, B two composite index field to do the time, who is at the front, in the back who, if A first, then use the A index will effect alone, B alone is not ,vice versa. Similarly, the use of fuzzy query like, if you just use the preceding%, then there is the effect of the index, if the numbers match the double%, then the effect is no index
5, when the database is stored in date format, time zone conversion problem of how to consider?
A: Use the TimeStamp, referring to the reasons: Java programming time zone conversion problems encountered
6, which method Java Object class have?
A: Object in what ways
7, the difference between the HTTP protocol, GET and POST
A: Talking about the difference in HTTP GET and POST

Second, threads, design patterns, caching aspects

1, SimpleDataFormat not thread-safe, how to better use and to avoid the risk of it
A: On time format SimpleDateFormat security thread safety issue
2, how to look at design patterns, and simply talk about your understanding of the observer pattern
A: 1 , design patterns God with two horses, and implementation of the observer pattern class diagram
3, cluster environment, session sharing how
a:
1, session of the Java shared cluster
2, session multi-server sharing scheme, there is a solution is to use a fixed server to maintain special session, other servers share
4, distributed, clustered environment, how to refresh the cache, and how to keep pace?
Answer:
A, how to refresh the cache? 1, 2 refresh timer, a refresh active covering, each framework has a built-in cache refresh mechanism, or cache invalidation mechanism, and took Redis Ehcache example, have their own expiration mechanism, additional active refresh covered, just get the corresponding key data coverage to
B, how to keep the cache synchronized? The Redis has built-in cluster synchronization mechanism, namely replication, specific reference: Based Redis distributed cache, Ehcache also distributed cache synchronization configuration, you only need to configure different server addresses, reference: Ehcache distributed cache synchronization
5 , a SQL execution long time, how do you optimize, from what?
A:
1, to see whether the SQL table relates to the combination of multi-table or sub-queries, and if so, to see whether it can conduct business split, redundant or related field combined into a temporary table (business and optimization algorithms)
2, involving the list of queries, query whether the table is divided, after the results of the integration of single-table queries field
3, if these two can not operate, have to query the list, consider the query conditions corresponding indexed. Speed up queries
4, the history table separation (such as transaction flow table) for a large number of tables
5, separated from the main database, separate read and write, read and write to reduce the pressure against the same table at the same time, as the master-slave synchronization, MySQL has built the binlog achieve master-slave synchronization
6, explain analyze SQL statements, view the execution plan, analyze the index is to spend, and so on analysis of scan lines
7, see the MySQL execution logs to see if there are other aspects of
personal understanding: from the root up that is slow query MySQL take up more memory, then you can consider this aspect to the discretion of hand

Third, the three major aspects of the framework

1, Spring transaction isolation, and isolation of talk about the difference of each
answer: Spring Detailed Affairs
2, Spring transaction propagation behavior, and to talk about the difference each propagation behavior of
answers: Spring affairs Detailed
3, hibernate with Mybatis / ibatis difference, why choose?
Answer: Compared with Hibernate MyBatis of
4, with the advantages and disadvantages of Struts Spring mvc, so you can choose how to choose
answer: Spring MVC and Struts difference
5, briefly Spring transaction mechanism
ANSWER: Spring transaction mechanism
6, Spring 4.0 new features
answer: Spring4 new features

Fourth, load balancing, clustering related

1, the configuration weblogic load balancing principles and cluster
solutions: a, WEBLOGIC load balancing principle B, load balanced configuration and cluster (reference)
2, the Nginx + the Tomcat + the Redis load balancing, the separation resources, session sharing
Solution: Configuration Reference
3, nginx configuration files detailed --nginx.conf
answer: Nginx configuration file details

V. optimization related

1, Web project on how to optimize
Answer: I am finishing off this time, Web project performance optimization (finishing)
2, single mode in several cases? How to optimize?
ANSWER: 7 usage singletons
3, briefly and implementation of the principles thread pool
ANSWER: Principle and thread

Sixth, concurrency and security

1, project concurrent how to deal with? (We are the Web project)
Answers: high concurrency website solutions, which was also optimistic locking database, database read and write separation, message queues, the use of stored procedures, and so
there is a 2, briefly functional competence levels of authority and vulnerability scenarios and solutions to vertical privilege vulnerability (because we are permission levels that function right)
answer:
a, level of authority loophole, as shown below

Suppose institutions two users A and user B, wherein A 1, 2 and 3 permissions, user B has permission 2 and 3, it is assumed that the user B knows that a time, and to add their own rights. 1, this time is level permissions vulnerability.
Currently solution: 1, limiting the entrance, so that users can not edit your permission B 2, the user B can not be extended upward. The fundamental solution is to go deep into data permissions
answer: the level of authority and vulnerability solutions

B, vertical privilege vulnerability
answer: vertical privileges vulnerability cases and solutions
3, the picture on the platform how anti-hotlinking
answer: http download security chain principle: Field referer record http protocol to achieve
4, how to distinguish upload the picture is not the Trojan horse?
Answer: 1, 2 suffix upload pictures to see how the suffix is tampered with, each file has a magic number file upload - magic number
5, the principle of message queues and implementation
ANSWER: 1, message queues principle 2, in layman's language the message queue ActiveMQ

Seven databases

1, MySQL query field is not case sensitive area?
Answer: no distinction, even if the value does not distinguish (I had also asked the district does not distinguish between the size of the application meaning of what the interviewer did not put it out)
2, briefly database clustering and load balancing, distributed (I do not understand this)
solution: the database load balancing and clustering reference, Ref. 2
3, the structure and the advantages of stored procedures
answer: probably structural
advantages and disadvantages of stored procedures
4, principle and function triggers
answer: reference

Eight, Java underlying problem

1, SpringMVC principles and how to render the data is returned to the jsp / html?
A: Spring MVC is the core of the DispatcherServlet, through the DispatcherServlet a request, forwarded to the HandlerMapping, then reflected, and the corresponding Controller address inside @RequestMapping method, and finally by ModelAndView ViewResoler returns to the corresponding view. Specific reference: Works of Spring MVC
2, when a class object properties change, how to let the caller know?
A: Java event time to listen, that is, when set method to change the properties, triggers, this model can also be understood as an observer modes, see: simple cases and instructions observer mode
3, why rewrite equals to rewrite hashCode?
A: to determine whether two objects are equal, the comparison is its hashCode, if you override equals, for example, is implemented based on the contents of the object, while retaining the same hashCode implementation, it is possible that two objects is obviously a " equal ", but not the same hashCode. hashcode not the same, we can not conclude that the two objects are equal
4, talk about your understanding of the JVM?
A: A very important feature of the Java language is platform-independent. The use of Java Virtual Machine is the key to achieving this characteristic. As long as the Java compiler for the JVM, builds JVM code or byte code files can be appreciated. Java source files compiled into bytecode program, each instruction by the JVM will translate into machine code on different platforms, run by a particular platform.
JVM process of execution of the program:. I loaded. class files, II. Management and memory allocation, III. garbage collection

JRE (Java Runtime Environment) Java Runtime Environment program constructed by the JVM

Specific details: JVM tuning principle and
5, MySQL things isolation level?
A: MySQL isolation level things actually things with Spring isolation level, are 1, Read Uncommitted (read uncommitted content), 2, Read Committed (read submission), 3, Repeatable Read (can be re-read), 4, serializable (serializable) specific reference: MySQL things isolation level
. 6, Spring principle
a: the core is the Spring IoC and the AOP, IoC dependency injection and inversion control, which can be divided into injection injection set, configured an injection, the injection interfaces and the like. IoC is a container, is responsible for instantiating, locate, target and dependencies between these objects configuration application. Simple to understand: Java business logic of each process requires at least two or more objects collaborative work, but each object when using its partner, need frequent new target to achieve, you will find that the object coupling between the high. The IoC idea is: Spring container to manage these objects only need to process the business relationship itself just fine. As for what is Inversion of Control, the object is to get dependent manner reversed.
AOP does, aspect-oriented programming, the most direct manifestation of the Spring of things management. As relevant information Spring things, not elaborate, refer to: Spring annotation management style of things
7, talk about your understanding of the NIO
Answer: IO is a stream-oriented, NIO buffer is facing here not go into detail, with specific reference to: the difference between Java NIO and IO
8, the difference between ArrayList and LinkedList, Vector's?
A: Generally speaking can be understood as:.
1.ArrayList is to achieve a dynamic array-based data structure, LinkedList based linked list data structure.
2. For random access get and set, ArrayList feel better than LinkedList, because LinkedList to move the pointer.
3. For new and delete operations add and remove, LinedList comparative advantage, because you want to move data ArrayList
Vector and ArrayList similar, but are strong synchronization classes, namely thread-safe, relatively specific reference to: Compare ArrayList, LinkedList, Vector
9, several cases of casual single-mode, and select a thread-safe
a: type One example: lazy, hungry man, enumerations, static inner classes, double check locks and so on, thread-safe I choose the last option , double check the lock. Specific reference implementations: Java: writing seven singleton pattern
10, to talk about the red-black tree
A: algorithms and data structures have been my weaknesses in this area say that they fill it, without much success, and here I would recommend a : red-black tree
11, for example to talk about some sort, and explain the ordering principle
a: I will not elaborate here, we all look at Java implementation of several common sorting algorithm
12, the principle of MySQL indexes
a: index we all know that the role is to speed up queries, but the principle, I can not tell, direct it out here: MySQL index works
13, serialized principle and function
a: serialization (serialization) is an object with a string of words procedure described in section; deserialization deserialization these bytes is a reconstruction of an object into the process, mainly for propagation or HTTP WebService interface transfer process object parameters, can be found in particular: Java serialization mechanism and principle

Nine, concurrent projects and Tuning

1, few talk about thread-safe implementations?
A: What is thread safe? My understanding is that an object is being accessed simultaneously by multiple threads, but also to maintain its internal properties of sequential and synchronization is identified as thread-safe. Three ways to achieve thread-safe: modified volatile, synchronized and other keywords, or use the following java.util.concurrent library. As for the relationship between the two former reference: synchronized and volatile usage difference
2, internal methods, how to achieve better asynchronous?
A: We know that in fact, asynchronous thread to make another run, then how to create a thread? The first direct new Thread, a second new class that implements Runnable interface implementation. The third, managed by the thread pool is created, etc., here comes the better asynchronous, that is to say we avoid frequent new threads inside the method, you can consider a thread pool. How to create a thread pool? Here you can thread a new pool, but need to consider a single case, or when the initial program Qidong, you create a thread pool, so he ran, then when specific methods to create a thread by thread pools, asynchronous
4.3 why use the cache? How to understand the nginx + Tomcat + Redis cluster cache?
Answer: The most direct manifestation of this is to reduce the pressure on the database. Avoid frequent or read because the data is too large to affect database performance and reduce the likelihood of downtime procedures
Answer 2: nginx often used for static content services and proxy server, the application is forwarded to the back face of foreign service request. nginx cache itself can do, such as caching static pages or something. The Tomcat application server, Java Web processing program and much more. So you can understand, assuming that the user's request as a river, then nginx is equivalent to a water conservancy project, Tomcat equivalent tributary diversion of a section, and the equivalent of a Redis reservoirs next to the tributary. When you flood came, nginx different distribution of water flow according to withstand the intensity of your every tributary, in the case to ensure the normal operation of the program, distributed to each branch (tomcat) different water flow. The Redis is equivalent to a tributary of the reservoir, storing water, reducing the pressure, so that the amount of water behind the stable.
4, daily items, if you take over, you are ready to tune from what?
A: The first is to understand what it needs to be optimized, definitely need to optimize project performance bottlenecks or guessing about to encounter, and we will go to consider optimization. So how to optimize?
a, expansion, expansion of understanding, is the ability to expand parallel processing server, the server is simply added to increase the ability to handle the request, such as increasing the number of nginx, Tomcat application server, etc., or the number of physical servers, as well as to increase the bandwidth of the server, etc., it is considered here hardware
B, tuning, tuning, comprising a tuning system tuning and code. Tuning system that is faster processing, such as we have mentioned CDN, ehcache, Redis other caching, message queues and the like, the response speed between services, increase system throughput, to avoid complicated, as for tuning the code, these the need to accumulate more, such as reconstruction, factories, database tuning, then I do not really understand this, just know that indexing and storage process, with specific reference to: MySQL database tuning 21 best practices, database tuning other aspects to you look for it yourself
5, talk about your understanding of distributed
A: I personally understand: a distributed system is to split / traffic into multiple subsystems / sub-business to co-processing, a process called distributed, the specific reference in the evolution: Java distributed application technology architecture describes
6, Redis achieve message queue
a: the Redis implement message queue, Ref. 2
7, a summary of multithreaded other questions related to surface 50
8, and share a tuning tool program: how to tune JConsole troubleshooting Java program running observation and analysis, performed

Ten, handwritten code problem (includes SQL title)

1, assuming the merchant table A (id, city), transaction flow meter B (aid, amount, time) time represents the transaction time here, please write SQL queries with sales in each city per month (can answer in the comments in reply)
2, assume that an array a, int [] a = { 1, 3, -1, 0, 2, 1, -4, 2, 0, 1 ... N}; originally isolated greater than required 0 array, but due to the mass participation error or other reasons, lead to detect 0 and negative numbers, and now requires without the use of the new arrays and new collections (ie, using only the a array, because the array data is relatively large, and only can cycle) to achieve a positive number to the front of the array, the number of less than or equal to 0 into the end of the array (the answer may reply in the comments)

XI, design-related

The interview will be asked some questions about the design-related, such as
1, your data interface service was cut package, how do you prevent malicious data submission?
A: We can set up a business number in the interface transmission parameters inside, this number is used to distinguish whether the duplicate submission. Even though the data get caught, the person can not distinguish each field of your meaning, then, the role of business numbers came
2, assuming that the server is down often, you go to troubleshoot problems from what?
A: This will leave you Tell me what supplements can comment Reply


Source: Hackers send
protocol: CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/

Guess you like

Origin www.cnblogs.com/20560838q/p/12369287.html