You leave between BAT, only a thin face questions about these

For many years, I often can understand that some really serious work, but frankly showed a level of ability but not enough to pass the interview, usually two reasons:

1, "know not why." Doing it for years technology, developed many business applications, but it does not seem logical to think through the various technology options behind.

2, knowledge is fragmented, unsystematic. In the interview, the interviewer can not seem to complete, clear description of the system developed by his own, or related technology to use. Usually may work hard, or too Sike some implementation details, and did not look up look at these technologies.

Predecessors have been out of the pit, and later friends would stop "fought" a!
You leave between BAT, only a thin face questions about these

Java foundation
1, talk about your understanding of the Java platform? "Java is interpreted," this sentence correct?

Analysis of test sites:

For these general issues, you need to try to demonstrate their in-depth and systematic thinking, Java was also more comprehensive understanding of knowledge, we must avoid letting the interviewer feel that you are a "know not why" people. After all, understand the basic components and mechanisms, is the basis for a lot of things were daily challenges in diagnosis or performance tuning, I believe there is no recruiter will interview those who do not like the "love of learning and thinking," the.

Return to the topic, the understanding of the Java platform can be many ways to talk about it succinctly, such as: Java language features, including generics, Lambda and other language features; base class library, including collections, IO / NIO, network, concurrency, security and other basic class library. For more of our daily work application library, before the interview can be systematized sum up, help spot to play.

2. Compare the Exception and Error, in addition, abnormal abnormal What is the difference with the general run-time?

Analysis of test sites:

Exception and Error Analysis of difference, is to investigate the mechanisms of the Java process from the conceptual point of view. Overall, still in the level of understanding, as long as the interviewer explained clearly enough.

Our daily programming, how to deal with abnormal test of skills is more, I feel the need to master both.

First, understand Throwable, Exception, Error design and classification. For example, those who master the most widely used subclass, and how to customize abnormalities.

Many interviewers will ask for further details, such as, you know what Error, Exception or RuntimeException?

Second, understand and practice the elements of the Java language Throwable operation. The most basic grasp of grammar is a must, such as try-catch-finally blocks, throw, throws keywords. At the same time, we must know how to deal with typical scenarios.

3, talk about the Java reflection, dynamic proxy is based on the principle of what?

Analysis of test sites:

This topic My first impression was somewhat induced suspicion, may subconsciously think that is the use of dynamic proxies reflection mechanism to achieve, say not too wrong but somewhat incomplete. Function is the goal, there are many ways to achieve.

Overall, the study This question is another basic mechanisms of the Java language: reflection, it is like a kind of magic, the introduction of runtime introspection capabilities, given the surprising vitality of the Java language, by running operation metadata or objects, Java information in order to determine the flexibility to run the operation. The dynamic proxy, it is a widely used technology that extends out of the product development, a lot of tedious repetition programming, dynamic proxy mechanism can be elegantly resolved.

From the perspective of knowledge, knowledge point of this question involves relatively complex, so the interviewer can be expanded or dig a lot of content, such as:

Examine your understanding of reflection and mastery.

Dynamic proxies to solve the problem, what's in your business system application scene?

JDK dynamic proxies on the design and implementation of cglib, etc. What is the difference, and then how to choose?

4, Java IO provides what way? How NIO be multiplexed?

In the actual interview, from the traditional IO to NIO, NIO 2, of which there are many places open to expansion, involving all aspects of inspection points, such as:

Relationship and the difference between the underlying API function and design, InputStream / OutputStream and Reader / Writer is.

NIO, NIO basic composition 2.

Given scene, we were used to achieve different models, analysis and design BIO, NIO and other models and implementation principle.

NIO high-performance data provided by the operation principle is based on what, how?

Or, from the developer's point of view, what issues do you think NIO itself implements exist? What happened to the idea of ​​it?

5, how to ensure that containers are thread-safe? ConcurrentHashMap realize how efficient thread-safe?
Typical answer:

Java provides a thread-safe support at different levels. In the conventional set inside the frame, in addition to other synchronization Hashtable container, also provides a so-called synchronous wrapper (Synchronized Wrapper), we can call the method of packaging Collections class provides tools to acquire synchronization of a packaging container (e.g., the Collections.synchronizedMap), However, they are very coarse-grained synchronous manner, in the case of high concurrency, relatively low performance.

In addition, a more popular option is the use of contract and thread-safe container class provides, which provides:

Concurrent various containers, such as ConcurrentHashMap, CopyOnWriteArrayList.

Various thread-safe queue (Queue / Deque), as ArrayBlockingQueue, SynchronousQueue.

Thread-safe and orderly release and other containers.

DETAILED thread-safe manner, comprising synchronize from simple manner, on to a more refined, such as other concurrent ConcurrentHashMap locks for separation based on the like. Select the scene to look at the specific needs of development, in general, and general contracting scene in the container provided, far superior to the early realization of a simple synchronization.

6, interfaces and abstract classes to talk about what is the difference?

Analysis of test sites:

This is a very high frequency of Java object-oriented foundation problem, looks very simple question, if the interviewer Some little deeper, you'll find a lot of interesting places, can be investigated from different angles you a comprehensive understanding of the basic mechanisms and master.

such as:

For the syntax of the Java basic elements to understand whether accurate. You can define a substantially correct syntax interface, or a related abstract class inheritance to achieve, for heavy load (Overload), rewriting (Override) but there is a variety of subjects.

Use interfaces and abstract classes properly in software design and development. Do you know at least a typical application scenarios, using the master important foundation class library interface; master design methods, can be seen obviously is not conducive to the future maintenance of the code design review time.

Grasp the Java language features evolve. Now a lot of the framework is already based on Java 8, and gradually updated version support, acquire the relevant grammar, designed to understand is necessary.

Advanced Java
7, how synchronized the underlying implementation? What is the lock upgrade, downgrade?

Analysis of test sites:

The main problem today is to examine the implementation of the Java control of your built-locks, also complicated by the classic title. I was a typical answer given earlier, covers some basic concepts. If the foundation is not strong, some relatively obscure concept to understand, I suggest try to understand and grasp, even if do not understand, do not worry, in the follow-up study will gradually deepen understanding.

Personally, I think, be able to understand these basic concepts and mechanisms, in fact, for most concurrent programming is enough, after all, most engineers will not necessarily be lower level, more basic research and development, a lot of time to resolve to know it or not, the real but also on improving the practice of stepped pit.

I'll be back for further analysis:

From the source code level, slightly expand the underlying implementation of some synchronized and added some of the above answers the lack of details, some students asked easy part of this feedback. If you are interested in the underlying Java source code, but have not found the starting point, where you can become an entry point.

Understand and other contracting lock java.util.concurrent.lock implementation provided, after all, Java is not only ReentrantLock EXPLICIT lock type, I will combine code analysis of its use.

8, synchronized and ReentrantLock What is the difference? Some people say that synchronized slowest, words fly it?

Analysis of test sites:

Today's topic is to investigate the common foundation of concurrent programming problems, the typical answer I give is regarded as a relatively comprehensive summary.

For concurrent programming, different companies or interviewers interviewing style are not the same, there are some manufacturers like to keep asking you to extend or underlying mechanisms, and some like from a practical point of view, so you're ready to concurrent programming requires some patience.

I think, as one of the basic tools lock concurrency, you at least need to know:

Understand what is thread safe.

The basic use case synchronized, ReentrantLock and other mechanisms.

One step closer, you also need:

Master synchronized, ReentrantLock underlying implementation; lock inflation appreciated, downgrade; skew appreciated lock, spin locks, locks lightweight, heavyweight lock concepts.

Java.util.concurrent.lock master and contracting in a variety of different implementations and case studies.

Typical answer:

synchronized synchronization mechanism is built-in Java, so it was also called Intrinsic Locking, it provides mutual exclusion semantics and visibility, when a current thread has acquired the lock, other threads can only wait attempts to acquire or blocked there.

In previous Java 5, the only means of synchronization are synchronized, in code, can be used to modify synchronized method may also be used on a specific code pieces, the synchronized method essentially equivalent to the method of using a synchronized block all statements wrap .

ReentrantLock, usually translated as re-entry locks, locks for Java 5 is provided, it is basically the same semantics and synchronized. Re-entry lock code directly by calling lock () method to get the code to write more flexible. At the same time, ReentrantLock provides many practical ways to achieve many of the details can not be done synchronized control, for example to control fairness, that is fairness, or the use of defined conditions. However, coding also need to pay attention, you must explicitly call unlock () method releases, otherwise would have been holding the lock.

ReentrantLock performance synchronized and can not be generalized, earlier versions synchronized in many scenes performance difference between the larger, more improvements made in subsequent releases, the performance may be superior in low ReentrantLock competition scene.
You leave between BAT, only a thin face questions about these
You leave between BAT, only a thin face questions about these
This information is Xiao Bian recently spent several months time to sort out, want to get the above information
click on the " learn more " to get free

Guess you like

Origin blog.51cto.com/14416052/2421057