More Java interview materials (OS, Networking, ZK, MQ, Redis, Java, etc.) :github.com/yuhaqiang12…

After the interview with Monkey Coach, Qunar, Kuang Shi, Momo, Toutiao, Ali, Kuaishou, Meituan and Tencent, the author has not only learned a lot of interview questions, but also thought about how to be a “tech-loving, thoughtful, reliable and potential candidate” in the eyes of the interviewer.

1. Interview Questions (Java backend)

Apes tutoring

1. Eight Queens problem 2. Finding the longest distance of binary tree (the longest of any two nodes' paths) 3. A data structure is designed to meet the requirements of the put and getMedium(median) methods. Rabbitmq high availability strategy (asked because of the overlap between the rabbitMQ project and their technology selection) 6. The details of the project include: did you compare various schemes when designing the scheme? Why did you choose this scheme? What has been your most personally fulfilling and challenging job? Thinking: 1. The arithmetic questions asked by ape guidance belong to Leetcode easy, medium level, which is basically not too difficultCopy the code

Kuang (Python)

1. How to implement multithreaded/multiprocess programming in Python 2. Why is there a GIL 3. Have Python coroutines ever been useful? 4. How to implement python decorator, how to work, and how to use it? 5. Python is a bunch of libraries I haven't heard of, have I used it? Given a Linux path, find the simplest path, for example (/a/b/.. -> /a, A /b/./. -> A /b, etc.) 7. Here is a 16-core, 32GB machine with distributed storage with unlimited space. Sort a 16P text file. File each line one record, space split for example key1 key2 8. The interviewer and I were crazy about Python. We didn't ask about any project experience. In addition to Leetcode, take a look at high concurrency, big data related system design problems.Copy the code

Where to go (Java)

1. Why to use MQ, how to select MQ, how to ensure message reliability, how to ensure idempotent 2. Have you ever used dubbo? Design a RPC framework. 3. Introduce HTTPS 4. Database thread pool, HTTP connection pool have read the source code? 5. Give you a billion pieces of data, how to add them to the database the fastest 6. 7. Java thread synchronization methods, countdownlatch and fence difference 8. Synchronized and AQS how to achieve reentrant lockCopy the code

Momo

1. Comparison of distributed lock implementation schemes, why ZooKeeper is selected, and principle of the ZooKeeper consistency protocol 2. Consistent Hash principle, implementation, how consistent Hash is used in the project, how many virtual nodes are introduced? 3. The principle of Java synchronized and AQS, the difference 4. Redis ordered list 5. The difference between CoDIS and Redis cluster sharding How do two threads alternately print 0 to 99Copy the code

The headline (Go)

1. Given a Linux path, find the simplest path, for example (/a/b/.. -> /a, a/b/./. -> a/b etc.) and the sight is heavy 2. Implement prefix tree 4. Implement Python decorator. Method implementation, and class implementation, with and without parameters. 5. How to realize the monitoring of network health before multi-machine rooms and multi-racks. How to understand process context switch, process address space, why need process address space, system call implementation principle, top command introduction.Copy the code

Ali.

1. Mq message reliability, how to ensure idempotent 2. Distributed lock implementation scheme comparison, why choose ZooKeeper, ZooKeeper consistency protocol principle 3. What problem does consistent Hash solve, and how is it implemented? What does a virtual node do? 5. Java lock implementation, comparison? AQS implementation principle? Is fair not fair realization principle? CAS implementation principle 7. Volatile implementation principle, singleton pattern 8. Java memory model, GC tuning experience What are the common parameters that can be optimized? Mysql transaction isolation level mysql transaction isolation level mysql transaction isolation level Why use B+ trees. And when is the index unavailable? Spring AOP: How to define new Spring XML tags How to design a security system for a large event (Open question) 16. What forums do you study on? 17. How to learn an unknown skill? Consider: Ali although the interviewer does not face algorithms, but the interview research point all-round attack, from shallow to deep, hold on until you do not. It is the most rewarding interview and also the interview where you feel the gap.Copy the code

Well quickly

Mysql index 4. Mysql transaction isolation level 5. Java lock and common thread synchronization mode 6. Zookeeper distributed implementation mode and advantages and disadvantages: How to prevent multiple clients from obtaining locks at the same time? Find the common node of two nodes in binary tree 8. Find the depth of binary tree (non-recursive) 9. Common Classes and principles of Java collection 10. Threading modelCopy the code

Meituan

1. How does HashMap work? How does capacity expansion work? Why did JDK 8 change the insertion location of conflicting linked lists? 3. The difference between HTTP and RPC calls 4. How redis supports high concurrency with single thread, common usage scenarios of Redis 5. Why use MQ 6. Consistent Hash principle 7. Meituan takeout payment requires cancellation of outstanding orders within 15 minutes. How to implement 8. Print * asterisk isosceles triangle 9. Full-link architecture of the project, single point problems, common solutions to single point problems 10. 11. Tell me about the most complex project you worked on, the number of people involved, and the length of the cycle. What do you think are your strengths and weaknesses What is your career plan for the future, what is your expected work content and direction?Copy the code

Tencent (Java)

1. How to obtain CPU cores in physical machines and containers, how to set the number of threads, and how to actively trigger GC 2. Consistent Hash, what Hash does, why it's called consistent Hash, what consistency is. What other ways can Hash conflicts be handled in a HashMap? 3. Thread pool parameter, optimization, principle 4. Implement a function: the cat/usr/local / *. The log | grep tencent 1. The result must be returned within 2.30 seconds. Java implementation principle 6. Java blocking queue implementation principle 7. Java lock volatile implementation principle 8. Mysql index principle, transaction isolation level, what are the scenarios of mysql deadlock, how to detect deadlock internally? 9. What are the tools for Java thread synchronization? 10. What do you think is better about Java design? 11. How to understand object-oriented design, can you use the open source code you read or actual project introduction? Java memory model, default size of vm stack 14. Talk about the common solution to the high availability architecture thinking: Tencent one side of the interviewer research point is very in-depth, requiring you to have the ability to summarize. For example, load policies and synchronous data backup schemes are common in distributed scenarios. Several ways to synchronize threads and so on. And you can press further after you answer. Unlike other interviewers who throw questions, he listens to you. He thinks you can blow as much as you can.Copy the code

thinking

  1. Hand tearing algorithm need to prepare, before the interview to ensure that brush enough 100 questions, and some design questions.

  2. Either way, don’t panic. Whether or not, be sure to check with the interviewer if you understand the question correctly. How should you think about this question? Avoid running deviation

  3. The interview is about communication.

    3.1 Forced conclusion

    Be sure to communicate logically with the interviewer. Avoid one broom east and one broom west. It’s best to think of some conclusions in advance and repeat them a few times. In this way, the interviewer may directly use your “conclusion” to write the interview process, conclusion, evaluation, etc. When you say one thing, it’s best to come to a logical conclusion that will impress your interviewer. Even imposing 1,2, and 3 bullet points is better than stopping short.

    3.2 Gracefully interrupt the current question, exit the discussion only at the checkpoint, and respond to the interviewer’s interruption

    When the interviewer has a question, throw out the question, interrupt your answer, must not blindly answer, immediately respond, grasp their own pace, first the interviewer for advice, can finish the rest. Continue speaking quickly and summarize your conclusions agree to disagree to avoid arguments

    The interviewer is not as familiar with your project as you are with your experience. Speaking, listening and discussing. There is a loss of communication information in all three stages. It may be difficult to make your interviewer understand and agree with you. However, if there is an argument, it will reduce the goodwill of you and reduce the effectiveness of communication. So it’s your responsibility to end the argument in time. Here are some tips to use:

    1. Restate the context, purpose, present situation, background, pros and cons. Honestly admit that this part of our design, implementation is not perfect. What optimizations have we come up with (proposed solutions). But priorities are not very high (prioritization is the best way to dump the blame). I was more focused on business goals. Not enough technology foresight. Your opinion really hit the nail on the head, and this question has bothered us for a long time. In the process of elaborating differences, it is actually to reach consensus. Some minor arguments, directly explain with the interviewer, ignore. Lay out what you agree on. Then say: "What is the main difference between us, in fact, every time I make it clear, and then for the interviewer to explain, or blame, we want to optimize, because the priority. We wanted to do so, but due to lack of time, or XXX at that time, we did not do so. But then we did suffer a loss, which was considered technical debt."Copy the code

Interview questions

Is a resume important? I don’t know what to do

Be careful with your resume. One of the questions that interviewers will throw at you, in addition to the usual interview questions, is what you write on your resume. Make sure you understand everything in your resume! Whether you write to understand, or to master. Otherwise, don't write what I don't think is necessary. 1. 3. Github does, but I haven't been asked about projects on GithubCopy the code

Does the project experience ask?

Project experience is usually a must-ask in the interview. So the first step is to prioritize the highlights of your project and write out clearly what you have done. Self-introduction stage focus should also be their own project experience, then it is best to prepare a speech in advance to say their own project highlights. Practice several times more. Avoid however brain, the Yellow River burst its dike type answer, think of where to say where.Copy the code

What about common high-frequency problems?

Java locks, thread synchronization,Juc packages. Thread pool memory model, GC tuning mysql indexes, locks, transaction isolation levels. Common distributed high availability architectures redis, mysql, ZK, MQ, etc. Data synchronization, data fragmentation, data backup, etcCopy the code

Do I need to brush?

Ari doesn't usually ask too many algorithms. But at least half of all companies use hand-ripping algorithms. You won't have much trouble getting 10 or more leetcode questions of any type. Would it be a pity if you did very well in the interview, but were dismissed because of the algorithm? Algorithmic questions are useful for expanding one's mind. It also exercises one's coding skills. I suggest whiteboard algorithms are very concise in Python. If you do a really good job in the interview, you'll be a good match for the job. Algorithm questions can be waterproof, will pick simple questions to ask. The purpose is to leave you, afraid you can not answer, to avoid embarrassment but their interview is poor, algorithm questions are particularly good, will reverse the interview results? Basically not. The hand rip algorithm is just an aid. Project experience and basic interview questions are the core.Copy the code

May I ask the result of the interview?

If I don't get an interview with HR, or if the interviewer doesn't make it clear that HR will contact me in the final interview, I will almost always ask. Or ask yourself about your weaknesses. They usually tell themselves. In addition, the manual tear algorithm OK will also be brushed away. When I was on Momo, the hand rip algorithm was perfect, but it still died.Copy the code

How many rounds of interviews?

Not counting HR, basically three rounds. But if the second-round interviewer starts talking nonsense, introducing you to projects and asking about your career plans, the second interview may be the last. If not sure, ask the interviewer.Copy the code

Can’t you cram for a job interview?

No. When the interviewer pressed the details of the project, if you are not particularly familiar with the details, do things carelessly, the technical depth is not enough, such as the selection of technology why do so, other plans? What are the advantages and disadvantages? If you don't do your research, you'll quickly give away the truth in the interview. If you are not familiar with the overall structure of the project and are only familiar with your own modules, you may be asked about related modules by the interviewer. If you are not familiar with the project, you will immediately falter. If you say that this area is not my responsibility and I am not familiar with it, it will make the interviewer suspect that you are not aware of the big picture and lack of initiative. "I can only finish the work in my module, and I have no understanding of the whole system, and I have no strong initiative consciousness. "Self-motivated" work may focus solely on the business and not pay enough attention to the technology applied to the project. You will be grabbed by the interviewer during the interview. If you don't think clearly and are not aware of this technical risk before the interview, you can put yourself at great risk. Meituan interviewer once asked me how to introduce a project with the largest number of participants, the longest cycle and the most complex that you are mainly responsible for. If the work is not active, do not take the initiative to think, the interview is presented with such a problem. Basically speechless.Copy the code

Can you just read blogs and understand the frequent interview questions? (Question-driven interview preparation)

It has to be done. Ali: Why does GC have to stop the world? Most blogs don't give clear, intuitive reasons. How to implement consistent Hash? Tear it by hand. Why is it called a consistent hash, and what does consistency mean? General blog no. Lru algorithm hand tear. There are blogs. Can you just read them and tear them up? How to select redis and ZK distributed lock implementation? Disadvantages, advantages? How to avoid the negative impact of shortcomings when using the project? How to realize the fairness of obtaining lock based on AQS? The interviewer will even pit you for a false statement to see if you can refute it. I've been stumped by thread pool questions before. The interviewer asked: Do I go to Max size first or do I go to the blocking queue first? I said the blocking queue will continue to create threads until the Max size is full. Interviewer: Is that right? So if it's an unbounded queue, wouldn't it never get to Max size? And I thought, yeah, that makes sense, I might have misremembered. And then the interviewer took her by the wayside. So the conclusion is, it's not enough to just read it and write it down, but to understand it deeply. Always study with questions in mind. Question driven learning. In the end, you will find that after a long time, you are most impressed by the questions you asked and the solutions and answers.Copy the code

More information :github.com/yuhaqiang12…