What you need to know for a programmer interview

1. Basic requirements The

basic requirements refer to the knowledge that you must learn, and most of the content in it has a very high probability of appearing in the interview. Therefore, this part of the content you have no choice but to choose to eat it, you can spend a year, you can spend ten years, or you can take it into a coffin to study.

1) The basic part of the language:

The first of the basic requirements, of course, is the basic part of the language. The basic part is actually the grammar and the function of some keywords, such as some basic grammars such as if/else, for loop, and some basic keywords such as new, class, and public. In most cases, interview questions are relatively small. , because of this part, as long as you have written Java for a few years, there is basically no problem.

Then the focus of the basic part is actually the keywords of static, final, transient, and volatile, as well as the high-level syntax of inner classes and generics.

When it comes to static, the most important thing to remember is that variables referenced by static in class properties will be used as the root node of GC. Being a root node means that this type of variable is basically not recycled. Therefore, static can easily introduce the risk of memory leaks.

If an interviewer asks you to explain the static keyword, and you tell him that static can modify properties, methods and inner classes, and what effect it has after modification, then the interviewer will basically not remember your answer, and the whole impression is mediocre .

But if you have finished speaking, add that you have encountered a memory leak problem, which was caused by a variable of type Map modified by static, and finally checked the stack information to find the problem and solved it. question. Then, the interviewer's impression of you at this time will unnaturally improve a bit.

Moreover, for static, a deeper understanding is that static will directly refer to the referenced properties, methods and inner classes with the class, rather than with the instance of the class. That's why, you can use classname.property, classname.method and classname.inner classname to directly refer to a property, method or inner class modified by static.

If you do not use static modification, then you must use an instance to refer to these methods, properties or inner classes, the most typical of which are inner classes. I believe many students have wondered why an inner class that is not modified by static must be declared like this.



Because you didn't use static to modify InnerClass, you must new out an instance of OuterClass to create an instance of the inner class on this basis, because the inner class can only be referenced through the instance of the outer class. If you use the static modifier, then you can use inner classes like this.



The biggest difference between these two methods is that in the first method, if you want to get an instance of InnerClass, you must have an instance of OuterClass, so in fact, you create two instances in this way, so there are two new keywords . The second way is easier to understand. The static inner class does not depend on the existence of the instance of the outer class, so it is only necessary to directly create an instance of the inner class, so there is only one new keyword.

Static is a bit too much, but LZ actually not only said the static keyword, but also roughly said the syntax of the inner class. Then, there is another thing that is more challenging in the basic part, which is the volatile keyword.

The focus of this keyword is three words, that is visibility. But during the interview, if you say the three words visibility, basically if you get a full score of 100, you can only get a maximum of 20 points. For the remaining 80 points, you have to work hard to get it.

The so-called hard work is actually to understand exactly what visibility means in concurrency. So, in order to understand what visibility means, you need to understand what main memory and working memory are.

Only by understanding these concepts, you will know what the real role of volatile is. But one thing to remind you is that volatile does not guarantee synchronization, this must be remembered. Not only to deal with the interviewer, but also to pay attention to this when using volatile, otherwise problems will easily occur.

Well, let’s talk about the basic part. LZ picked some representative ones to talk about. In the final analysis, this part is to ask you to have a very clear understanding of the keywords and syntax in Java. The so-called understanding here is clear. Understand its implementation principle, not just use it.

2) Java runtime environment

Java runtime environment is the Chinese translation of JRE, which essentially refers to JVM.

The first thing you must know about the JVM is the relationship between the JVM and Hotspot. JVM refers more to the JVM specification, and Hotspot is an implementation of the JVM, and it is also our most commonly used JVM implementation. You can think of the JVM specification as an interface and Hotspot as an implementation class, which makes it easier to understand.

In addition, the three most important parts of the JVM must be very clear, memory division, class loading mechanism and GC strategy. Knowing these three parts is not only for the interview, but also to give you a deeper understanding of Java, which will be very helpful for your Java career.

Moreover, there is another point to note about memory division. The division method we often talk about actually refers to the division method of Hotspot, not the JVM specification.

The memory division of Hotspot is simply divided into three parts, Young Generation (young generation), Old Generation (old generation) and Perm Generation (permanent generation). Among them, the Young Generation is divided into Eden, From and To, of which From and To are collectively referred to as Survivor Spaces.

Under normal circumstances, from creation to destruction, an object should be from Eden, then to Survivor Spaces (survivor area), then to Old Generation (old generation), and finally disappears under a certain GC.

Of course, an object may also die directly in Eden, or it may always survive in the Old Generation (old generation), these are all possible.

Regarding memory division, you can use memory analysis tools, such as jmap, jvisualvm, etc., to observe the memory changes in various areas, and to understand the actual situation.

Regarding the learning of the classloader mechanism, you can learn it in combination with tomcat, understand the classloader mechanism of tomcat, and see how tomcat ensures the class isolation between each APP. If possible, take a look at the source code of the classloader in tomcat, or take a look at niubi-job, an open source project by LZ, which also contains parts similar to the tomcat class loading mechanism.

As for GC, you need to know what GC Roots have and how to judge whether an object can be recycled. In addition, the algorithm and strategy of GC should also have a general understanding. For details, please refer to LZ's articles on this series at http://www.cnblogs.com/zuoxiaolong/category/508918.html.

3) Concurrent knowledge and concurrent packages

If you want to enter the first-tier Internet companies, you must know this part of the content, otherwise, you can only stay in a relatively low segment.

Regarding concurrency knowledge, the two most important concepts must be clarified, that is, visibility and atomicity. Among them, visibility is closely related to the volatile keyword mentioned above. Visibility is only a concept in the field of concurrency, and volatile is a keyword in the Java language that actually guarantees the visibility of variables.

As mentioned earlier, to figure out visibility, you need to figure out main memory and working memory. Regarding main memory and working memory, it actually belongs to the knowledge category of JVM. So it can be seen from this that knowledge is related.

Compared with visibility, atomicity is actually better understood. I believe that the example of the transaction of bank remittance, which is unchanged for thousands of years, is enough for most people to understand the concept of atomicity. It is actually one or more operation, which is regarded as the meaning of a whole.

Once you have the basics of concurrency, you need to look into the concurrent package. The stuff here is actually a treasure. Once you need to write concurrency related functions, you will find the stuff in it very useful.

Among them, ConcurrentHashMap is the easiest class to be asked in interviews. Almost all interviews will ask you what is the difference between ConcurrentHashMap and ordinary synchronous HashMap.

This problem actually requires you to know two things, one is the data structure of HashMap, and the other is the technology of locking segmentation.

In addition, there is a very important class in the concurrent package called AbstractQueuedSynchronizer. Almost all concurrent tool classes in the concurrent package are extended based on this abstract class. Therefore, a thorough study of the AbstractQueuedSynchronizer class is very helpful for you to understand the concurrent package.

Finally, a question that is often asked during interviews is what is the difference between ReentrantLock and synchronized keywords.

I remember that in the YY interview organized by LZ before, LZ asked this question many times, but almost everyone could not answer it. This can only show one problem, that is, when most people use synchronized and ReentrantLock, they do not consider which one is better.

In fact, the difference between them is very simple. In short, synchronized is a mutual exclusion implemented by the underlying JVM, so the efficiency will be higher. ReentrantLock has more functions than synchronized, such as acquiring a lock regularly, multiple waiting conditions, etc.

This part of concurrency is an important part of a programmer's advancement, and I hope all Java programmers can pay attention to this part.

4) Design patterns and reflections

Design patterns and reflections, LZ personally thinks are the parts that a high-level programmer must be proficient in.

With this part of knowledge, you can write less code in actual development, and you can also make the structure of the program better.

I won't introduce more about the design pattern LZ here. For details, you can read the LZ design pattern series articles at http://www.cnblogs.com/zuoxiaolong/category/509144.html.

Regarding reflection, it is actually the content in the reflect package. The classes in this package are actually not difficult. The main thing is to use more and see more. For example, the most commonly used spring framework in the Java field is actually full of real usage scenarios of design patterns and reflections. Doing more research will definitely benefit you a lot.

5) File IO, NIO, network IO and network protocol

files IO, NIO and network IO are also frequently used parts in the work, so they must also be mastered.

Among them, NIO is more about understanding its principles. In addition, there are multiple protocols implemented in tomcat, including BIO, NIO and APR. These three must be very clear about their differences. This can be configured in the protocol property of the connector.

As for the network IO part, it is actually the content of the net package. The contents here are very commonly used things. For example, if you call HTTP-API, you need to use the classes here. In this era of the proliferation of restful-APIs, you must use the HTTP protocol to call APIs.

In addition, when understanding this part, the network protocol should also be properly understood. The most typical TCP and HTTP protocols must be understood.

In the interview that LZ participated in, basically the TCP protocol will be asked. Although this may be related to the TCP protocol written in LZ's resume, such as the retry mechanism of the TCP protocol, the three-way handshake process, and the difference between TCP and UDP. A type of knowledge that still needs to be understood.

As for the HTTP protocol, it is relatively simple. The application layer protocol mainly needs to know its protocol format, such as which headers are supported, what each header means, and so on.

6) The summary

is good, so far, the basic requirements are almost finished.

If you want to enter BAT, you must understand the content of this part, and the content of this part is also very helpful for your actual development, not just for interviews.

2. Optional requirements

Seeing the four words optional requirements, many people may think that this part is not very important. But LZ can tell you responsibly that this part is often an important indicator to decide whether the company wants you or not.

Because after the basic requirements are met, the company's main criteria for selecting talents is actually the optional requirements

. 1)

In fact, there is no need to say more about the Spring and Mybatis frameworks. If you can be very proficient in the principles and source code of the spring and mybatis frameworks, Then this must be a huge advantage for you.

If you are a Java back-end ape specializing in WEB development, then the spring and mybatis frameworks are basically what you must use. Being proficient in Spring and mybatis frameworks is not only for interviews, but is also of great help to your daily development. You can do a lot of architectural optimizations and save a lot of repetitive work for your comrades-in-arms.

Regarding the Spring framework, the core is of course IOC, followed by AOP and MVC. Studying the source code of these three parts will make you stand out from most programmers. As for the mybatis framework, the main focus is on how it implements dynamic SQL.

Moreover, after you have thoroughly researched, you can completely try to build a wheel yourself, and you may get unexpected results.

2) This part of Linux server

is actually the part that operation and maintenance should be proficient in originally, but as a Java back-end ape, if you can be proficient in Linux server, it will be of great help for you to troubleshoot online problems.

Most programmers only know some common Linux commands, but they don't know anything about the file system, network, IO, etc. of the Linux system itself, which actually includes LZ itself. However, LZ has seen some programmers around him who are very proficient in playing Linux. This is not only reflected in a few more commands, but also in the understanding of the entire Linux system.

It is foreseeable that when these people troubleshoot problems, it is often easier to find the root of the problem. Because program problems are often not the most difficult to solve, and if you see exceptions a lot, you will know what's going on. If you look at the source code, you can always find the reason. The most difficult to solve is the environmental problem, and the environmental problem is nothing more than a problem at the operating system level.

Obviously, in most cases, the operating system that Java runs on is Linux.

3) Database optimization

After talking about Linux, what LZ wants to talk about is the database, which should be the part that DBAs should be proficient in originally, but as a Java back-end ape, the database is basically the most frequently dealt with.

And we all know that the performance bottleneck of an application often occurs at the database side. Therefore, if a Java back-end ape can be proficient in the database, it will be of great help to your work.

I believe that many people have encountered the situation that SQL is too slow. At this time, how to optimize the execution time of SQL to an acceptable range by adding indexes, SQL analysis and optimization is actually a test.

Anyway, the LZ of this thing is about half a pound. There is no problem with basic optimization, but it will not work if it is a little more complicated.

So, this part is enough to be your advantage and reflect your difference.

4) Message service

In addition to Linux and database, message service is also an indispensable component in today's Internet companies.

Common message components such as rabbitMQ, activeMq, including some other open source message components, such as rocketMq. Any one of these, if you can master its principles, will also become a powerful competition condition for you.

In fact, the focus of the message service is nothing more than how to ensure the eventual consistency, the order of messages, including message transactions and so on.

Although LZ himself does not know much about this, LZ is sure that if you can have your own unique insights in this part, it will greatly increase your success rate.

5) Cache service

After talking about the message service, I believe that the cache service must be familiar to everyone.

Common caches such as memcached and redis, if you can figure out one of them, it will give you a lot of extra points. After all, in today's Internet applications, caching is also essential, so if you can completely hold this part of caching, then your difference will be there.

In the cache service, there are several common problems, such as what to do when the cache is full, how to deal with the real-time performance of the cache, how to plan the memory structure, how to deal with the cache hit problem when adding or deleting nodes in a distributed situation, and so on.

6) Load Balancer

Load Balancer, this is the last optional requirement.

There are two common load balancers, one is soft load balancing, such as nginx, Apache, and lvs. The other is hardware load balancing, and the most common one is F5.

These two methods have their own advantages and disadvantages. Among them, hardware load balancing should be used for simple applications and large access scenarios, while software complex balancing is mainly used for complex applications and small access scenarios. Of course, there is another difference that has to be considered. Hardware complex balancing is generally very expensive, while soft load balancing basically costs nothing.

On the load balancer side, there are also some issues that are more common. For example, how to maintain the session, how to do traffic control, what kinds of load balancing strategies are available, how to check the health status of the backend server, and so on.

7) The summary

is good, here, the optional requirements are almost the same.

Careful ape friends will find that these six requirements actually correspond to some of the most commonly encountered things in Java back-end development. For example, the spring framework and the database, both of which are basically all Java programmers have come into contact with.

The other four include Linux server, message service, cache service, and load balancer. The same is true. Everyone should have been exposed to these things more or less in actual work.

But I believe that there are not too many people who can really understand and master one of them. Because of this, if you do it, you can reflect your difference, which may be one of the important chips for you to win the offer.

However, what LZ has to emphasize here is that most people will have some understanding of these things, including the questions mentioned by LZ above, and many people also know the answers.

However, just knowing the answer is not enough, it is not enough to be your advantage, you need to have a deep understanding of these questions and have your own unique insights, it is enough to make it your advantage.

3. Bonus requirements

The last one is the bonus point requirement. Although the bonus point requirement is not as important as the basic requirements and optional requirements, it is also similar to the optional requirements. The final reason for winning an offer is often the parts that seem to be unnecessary requirements. Among these extra points requirements, in some special cases, may become basic requirements.

1) Needless to say, this part of data structure and algorithm

is well understood by everyone. Proficient in data structures and algorithms will definitely become a highlight for you.

Because most programmers have a poor foundation in this part, including LZ himself, if you ask questions about algorithms during the interview, LZ basically has two words: no.

In the past, LZ has also seen some source codes of the Java collection framework, and has a certain understanding of some commonly used data structures. But now, LZ has basically forgotten, and even the most basic bubble sort may not be able to write correctly.

Therefore, it is foreseeable that data structures and algorithms are definitely a plus. And, when you're interviewing for some algorithm-related jobs, this bonus requirement may also become a basic requirement.

2) Computer operating

system The principle of computer operating system is very low-level content.

This part of the content is more difficult, and it talks about some of the most basic underlying principles, such as memory, instructions, system IO, and so on.

3) Computer network

In fact, this part of the network is still more important for programmers.

What LZ is doing recently often encounters some network problems. Although many times, these problems can actually be solved by specialized network personnel, but if you don't know enough about it yourself, you will still have problems with your work. cause a great obstacle.

Moreover, if you want to be proficient in the TCP/IP protocol, if you don't understand the computer network, it is still difficult to really understand it.

Therefore, if you can be proficient in the computer network part, this will definitely be a plus for you.

4) Proficiency in a scripting language

Scripting languages ​​are very convenient in many cases, and they are also very practical.

LZ has been forced to use Python to do a lot of things recently. In fact, after you use it, you will find that although Java can achieve the same purpose, choosing the right language will save you a lot of energy.

Therefore, if you can be proficient in a scripting language, such as Python, shell, etc., this will also be a plus for you.

5) To sum

up here, the requirements for extra points are almost the same.

In fact, there are many more points that can be added. LZ only lists the more common ones. For example, if you have a background in other first-line Internet companies, you can also add points. It's just that this kind of bonus item is more difficult to achieve, and more grassroots programmers are mentioned here, so LZ doesn't say much here.

In general, bonus requirements are as critical to your success as optional requirements, so if possible, you should work on the bonus requirements.

Learning Summary

About the learning part, it's almost the same here.

In fact, most first-tier Internet companies have only two technical requirements for recruiting people, a solid Java foundation and one skill.

A solid Java foundation is actually part of the basic requirements in this article, and a skill is actually just any one of the optional requirements and bonus requirements.

Of course, it is undeniable that among the optional requirements and bonus points, the more you know, the higher the success rate, there is no doubt about this. But if you have no advantage at all, even if you have a solid Java foundation, it is actually difficult to get in, because there are too many people like you to stand out among the many interviewers.

Although it is not ruled out that you were very lucky, the company was in desperate need of people at that time, and there were no other better candidates, so you were lucky to get the offer, but after all, this probability is really too small.

After all, knowledge is there, neither running nor moving, it depends on whether you learn it or not, and when you learn it.

Some people reach it within a year or two after graduation, some take three to five years to reach it, and some people never reach it in their entire lives. It's up to you what kind of programmer you want to be.

Quality

After talking about mentality and learning, let's talk about the quality a programmer should have. Although this part does not seem to be helpful for the interview, in fact, LZ sometimes thinks that this is more important than technology, because they may affect the development of your programmer career.

1. Code style

When it comes to the quality of programmers, the first is code style.

Although there is no absolute correct style for the code style, but on the premise of satisfying the basic Java code style, you should gradually form your own code habits, and it must be a good one.

To give the simplest example, no matter how good you are, if your variable names are named in pinyin, then others must have the impression that you are a very low programmer.

In fact, programmers are sometimes very similar to artists. An artist who focuses on painting generally has his own style. To exaggerate a little, maybe someone can recognize his paintings as long as they are taken out. This is actually a style.

As a programmer, you should also have your own code style, although at work, in order to better communicate with everyone through code, you more or less need to make some compromises and maintain a consistent style with everyone.

But your own open source project should be your work of art. When you carve it, you are actually forming your unique code style.

Moreover, sometimes, your open source project may directly or indirectly help you get a good offer.

2. Writing ability

Some people may be surprised to see this, but LZ personally thinks that writing ability is the quality a programmer should have.

Code style is only your literacy in writing code, you also need to have the ability and literacy to write text. Documentation and comments are also an important measure of a programmer's professionalism.

Because no matter how good your technology is, what others see, in addition to your code, is your documentation and comments. Whether this part can be written well, in many cases, directly determines other people's impression of you.

Therefore, writing ability is actually a literacy that a programmer should have, at least LZ always thinks so. Because no matter how powerful this person is, if his documents and comments are in a mess, and they don't reflect the word professionalism at all, then his image will definitely be greatly reduced in LZ's heart.

At the end

of this article, I briefly talked about how to enter BAT from three aspects of mentality, learning and literacy, but in fact, this is also a process for programmers to learn and improve themselves.

Guess you like

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