Java interview question answer sharing

  Some Java interview questions being interviewed, today I will sort out the answers to these interview questions.

  Introduce your work experience and introduce a recent project, what are you mainly responsible for?

  For work experience, just give a brief introduction, and control it for about three minutes. This is the beginning. After all, it is written on the resume. The introduction of the project varies from person to person. If you have done a taller project, just say it one by one; if the project is relatively simple, then you have to prepare in advance and try to put the project in Find out some of the highlights, organize your ideas, and prepare in advance how to answer this question. For what you are mainly responsible for, it is best to mention some of the things that are responsible for the project, preferably some core things.

  Have you done MySQL tuning, how to do it

  This topic will be related to some of your own experiences. It is roughly divided into two directions, one is the tuning of the MySQL server direction, including tuning by monitoring the MySQL server memory, CPU and io, etc., as well as some configuration tuning of MySQL, because I really have not been involved in this regard, just I won't elaborate on it for everyone. You can go to Google to learn.

  The other direction is SQL tuning, including analyzing slow query logs, viewing execution plans (explain), index optimization (primary key indexes, unique indexes, combined indexes, etc.), and querying to select only the required fields (if the index can cover the most OK) Wait.

  What are the MySQL indexes, and under what circumstances do not go index

  Primary key index, unique index, ordinary index, combined index (involving the principle of leftmost prefix), full-text index.

  The index failures are mainly in the following situations:

  1. The query conditions include or: if the left and right fields of the or query have only one index, the index will be invalid; if both the left and right fields of the or index have indexes, they will take effect.

  2. Like starts with% and does not go to the index

  3. The combined index does not use the first column index, the index will be invalid

  4. Using a function for a field in where will cause the index to become invalid

  5. If MySQL analyzes the full table scan speed is faster than the index speed, it will use the full table scan, the index is invalid

  Why MySQL chooses B + tree, how is it different from Hash index

  Everyone knows that MySQL's consumption is mainly on io, so the fewer the number of io, the better, and the tree height represents the number of io, so the lower the tree height, the better. The non-leaf nodes of the B + tree do not save the data corresponding to the key value, so the key value that can be saved by each node of the B + tree is greatly increased, so the tree height is reduced; on the other hand, all the keyword data exist in the leaf node, so The number of times of each search is the same, and the query speed is more stable; on the other hand, the leaf nodes of the B + tree are connected to the subsequent nodes, which is very useful for range search.

  Hash index is not suitable for MySQL for the following reasons: 1. Hash index has a special structure, so the query efficiency is particularly high, but it can not use range search, which is fatal; 2. For a large number of duplicate keys, Hash There will be the problem of hash collision.

  What are the MySQL transaction isolation levels

  1. Read uncommitted

  2. Read has been submitted (avoid dirty reading)

  3. Repeatable reading (avoid non-repeatable reading)

  4. Serialization (highest level, low performance, generally not used)

  The above are 4 isolation levels, the general database can be read repeatedly by default. You can google for more detailed content, as well as the concept of snapshot reading and MVCC.

  What's new in Java 8

  1. Lambda expression

  2. Streaming operation

  3. The function interface and the default methods supported in the interface

  4. Time tools, LocalDateTime, LocalDate, etc.

  5、Optional

  6.Optimized HashMap, ConcurrentHashMap

  7. The permanent generation has been removed from jvm and changed to MetaSpace

  What are the garbage collection algorithms

  1. Mark removal (there will be debris problems)

  2. Copy algorithm (applied in the young generation, there will be a waste of memory space)

  3. Marking and finishing (the efficiency will be lower)

  4. Generational collection (younger generation (less surviving objects, use replication algorithm), older generation (more surviving objects, use mark removal or mark sorting)

  Implementation mechanism of ReentrantLock

  The implementation mechanism of ReentrantLock is best to see the source code. The common methods are lock and unlock. Most of the core logic is in AQS. You can go to the article I wrote before.

  The structure of Java HashMap, what optimization did Java 8 compare to Java 7

  HashMap is an array and linked list structure. Red and black trees are introduced in Java8, and optimization is also done when expanding capacity. You can go to the HashMap source code analysis I wrote before.

  What are the parameters of the thread pool, and its implementation principle

  This interview question will be asked 100%. Just a few days ago, I organized the relevant knowledge of the thread pool, you can refer to it

  Java lock those things JDK lock (ReentrantLock)

  HashMap interview, after reading this article is enough (on)

  The Java thread pool is enough to read this article, the interview is no longer afraid

  I didn't expect that the answers to these interview questions were sorted out quite a lot. I sorted out the first half first and then sorted out the second half at night. When it's time to write a bug, everyone should go to work.

Guess you like

Origin www.cnblogs.com/javaxiachen/p/12707270.html