interview skills

1, the basic grammar

This includes the role of static, final, transient and other keywords, the principle of foreach loop and so on. In today's interview, I asked you what the static keyword does. If you answer static modified variables and modified methods, I will think you are qualified. If you answer static blocks, I will think you are good. If you answer static inner classes, I will think you are very good. , I will be very satisfied with the static guide package, because I can see that you are very keen on researching technology.

The most in-depth time, I remember that the interviewer directly asked me the underlying implementation principle of the Volatile keyword (by the way, interviewing and being interviewed are relative, and the interviewer asking this question also makes the interviewer feel that the interviewer is also a People who like to study technology increase the good impression of the interviewer on the company. I finally chose the company that asked this question), don't think this is too nitpicky - the simpler the question, the better you can see a person's level, others The vast majority of your technical considerations are based on depth first and breadth second, remember.

2. Collection

is very important and must be asked. Basically it is List, Map, Set. It asks about the underlying implementation principles of various implementation classes, and the advantages and disadvantages of implementation classes.

Collections need to master the implementation principles of ArrayList, LinkedList, Hashtable, HashMap, ConcurrentHashMap, and HashSet. If you can answer fluently, of course, it is better to master the CopyOnWrite container and Queue. Another thing to say, ConcurrentHashMap was asked a lot in the interview, probably because this class can generate a lot of questions. Regarding ConcurrentHashMap, I will provide three answers or research directions for netizens and friends:

(1) ConcurrentHashMap lock segmentation technology.

(2) Whether the reading of ConcurrentHashMap needs to be locked and why.

(3) Whether the iterator of ConcurrentHashMap is a strongly consistent iterator or a weakly consistent iterator.

3. The design pattern

was originally thought to be a very important piece of content, but it turned out to be only asked once during the interview of Alibaba B2B business department, and the decorator pattern was asked at that time.

Of course, we can’t be so utilitarian. We learn for interviews. Design patterns are still very important and useful in our work. Among the 23 design patterns, we can focus on the ten or so commonly used ones. The questions and answers about design patterns in the interview are mainly three. Directions:

(1) Which design patterns are used in your project and how to use them.

(2) Know the advantages and disadvantages of common design patterns.

(3) Can draw UML diagrams of common design patterns.

4. Multithreading

This is also a must ask. Because of three years of work experience, I basically won't ask you how to implement multi-threading. I will ask in-depth questions such as the difference and connection between Thread and Runnable, what happens when a thread is started multiple times, and the status of the thread. Of course, this is only the most basic. Unexpectedly, several interviews were almost all asked a question at the same time, and the method of asking was different.

To sum up, it means this:

if there are four threads Thread1, Thread2, ThreadD3, and Thread4 to count the sizes of the four disks C, D, E, and F respectively, and all threads are counted and handed over to the Thread5 thread for summary, how should it be implemented?

Do smart netizens have an answer to this question? Not difficult, there are ready-made classes available under java.util.concurrent.

In addition, the thread pool is also a frequently asked question. How many types of thread pools are commonly used? What are the differences and connections between these types of thread pools? What is the implementation principle of the thread pool? In practice, it will give you some specific scenarios and let you answer what kind of thread pool is appropriate for this scenario.

Finally, although there are not many questions in this interview, multi-threaded synchronization and locking are also the key points. The difference between synchronized and ReentrantLock, the common method of synchronized lock and the static method of lock, the principle of deadlock and troubleshooting methods, etc.

5. JDK source code

If you want to get a high salary, you must read the JDK source code. The above content may also be related to specific scenarios. The JDK source code is to see if you usually like to study. During the interview, I was asked a lot of questions about the JDK source code. The most tricky one asked me how the hashCode() method of String was implemented. Fortunately, I usually read the source code of String a lot and gave a general answer.

The JDK source code is actually nothing to summarize. It depends purely on the individual and summarizes the more important source code:

(1) Source code of List, Map, Set implementation classes

(2) Source code of ReentrantLock, AQS

(3) The implementation principle of AtomicInteger, mainly Can explain clearly the CAS mechanism and how AtomicInteger uses the CAS mechanism to implement

(4) the implementation principle of the thread pool

(5) the methods in the Object class and the role of each method

These are actually quite demanding. The source code of the important classes in the JDK has been studied over and over. It really took time and effort, and of course looking back, it was worth it - not just for interviews.

6. The framework is a

commonplace , something that must be asked in an interview. Generally speaking, you will be asked about the framework you use in your project, and then you will be given some scenarios to ask you how to use the framework. For example, I want to do something when Spring initializes the bean, and I want to do it when the bean is destroyed. How to do some things, the difference between $ and # in MyBatis, etc., these are more practical, and it is not a problem to accumulate well and learn the details of the use of the framework.

If you answered the above questions well, the interviewer will often ask in-depth how the framework is implemented. The most asked is the implementation principle of Spring AOP. Of course, this is very simple. It can be done in two sentences, even if you don't know how to prepare it. The most perverted thing I encountered was asking me to draw a UML diagram implemented by Spring's Bean factory. Of course, facing such a deep question, I absolutely can't answer it/(ㄒoㄒ)/~~

7. Database

Nine times out of ten, the database will also ask. Some basics like the difference between union and union all, left join, several indexes and their differences will not be discussed. The more important thing is the optimization of database performance. Before the interview, take a day or two to prepare the content of SQL basics and SQL optimization.

But don't worry about the database. A company often has many departments. If you are not familiar with the database and the basic technology is very good, 90% of them will want you. It is estimated that you will be placed in a department that does not require very high database usage. Get some exercise.

8. Data structure and algorithm analysis

Data structure and algorithm analysis, for a programmer, will be better than not and can definitely come in handy at work. Arrays and linked lists are the foundation. Stacks and queues are a little deeper but not difficult. Trees are very important. The more important trees are AVL trees and red-black trees. What is the difference between balanced tree, AVL tree and red-black tree. I remember an interview, an interviewer and I talked about the index of the database, he asked me: Do you know which data structure is used for the index?

I answered the Hash table used, and I answered incorrectly. He asked again, do you know why trees are used? I answered that because there may be more conflicts in the Hash table, in the face of tens of millions or even hundreds of millions of data, the time complexity of the search will be greatly increased. The tree is relatively stable, and it is basically guaranteed that the desired data can be found at most 20 or 30 times. Why do we think the index should be implemented using a tree?

As for the algorithm analysis, I don't know if I don't want to study it. I remember an interview where the other party asked me which sorting method the Collections.sort method used. Of course, in order to show my erudition, I also have some research on algorithm analysis (⊙﹏⊙)b, I still bite the bullet and say that it may be bubble sort. Of course, the answer is definitely not. Interested netizens and friends can take a look at the source code of the Collections.sort method, which uses a sorting method called TimSort, which is an enhanced merge sort method.

9. Java virtual machine
To my surprise, Java virtual machine should be a very important piece of content, and the probability of being asked about it in these companies is almost 0. You know, I spent a lot of time studying the Java virtual machine last year. I have read the book "In-depth Understanding of Java Virtual Machine: JVM Advanced Features and Best Practices" by Mr. Guang Zhou Zhiming.

Closer to home, although I didn’t ask about the Java virtual machine, I think it is still necessary to study it. I will simply make an outline and talk about the more important content in the

Java virtual machine: (1) The memory layout of the Java virtual machine

(2) ) GC algorithm and several garbage collectors

(3) Class loading mechanism, that is, the parent delegation model

(4) Java memory model

(5) happens-before rule

(6) volatile keyword usage rules

Maybe the interview is useless, but it is going big On the road of cattle, it is impossible not to.

10. Some questions

on the web Java is mainly for the web side, so some questions on the web must be asked.

The two most frequently asked questions I have encountered are:

talk about several implementations of distributed Session.

The four commonly used answers can naturally make the interviewer very satisfied.

Another frequently asked question is: talk about the difference and connection between Session and Cookie and the realization principle of Session. In addition to these two issues, the content in web.xml is the key point, Filter, Servlet, Listener, not to mention the realization principle of them, at least we can know the basics of their use. In addition, some details such as the difference between get/post, the difference between forward/redirect, and the implementation principle of HTTPS may also be examined.

Finally, if you are interested and have time, it is recommended to study and study SOA and RPC. Service-oriented systems are necessary for large-scale distributed architectures.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326697204&siteId=291194637