Transferred from: http://icyfenix.iteye.com/blog/715301
The background of this post is tonight to see JE on this posting: http://www.iteye.com/topic/715256, the words written on impulse, if you can, can have other interviewers to analyze their interview questions asked, it may be a very meaningful thing.
In the company as a technical interviewer for a few years, from graduating students to work more than 10 years of candidates have met. Let me start by expressing my own views on the interview:
1. Written test, interview to evaluate a person is certainly not accurate, understand a person the most accurate way is "road distance horse horsepower, long time see Heart". Through the one or two hours of doing the problem, communication, but there is no other way under the helpless, so through the interview does not mean how successful, did not pass also does not mean that there are many failures.
2. A good interviewer should not put himself on a commanding role when talking, and should treat himself and the candidate as equal communication between two people who do the technology, and regard themselves as authority often subject to the angle of view, language expression, the inertia of the Work field constraints.
3. A good review of the topic is that we can often contact, different levels of people can have different levels of the answer, can be extended from the problem behind the topic of further discussion.
For example, the following question I used to ask, from fresh to more than 10 years of working people have asked:
Reference
"Everyone knows that Java has something called a garbage collector, it lets the object created do not need to be like c/cpp, delete, free, can you talk about when the GC is, to what, what things?" ”
My own analysis of the problem, the first is "when", different levels of the answer from low to high rank:
1. When the system is idle.
Analysis: This answer accounts for about 30%, in general I will be ready to turn to other topics, such as algorithms, such as SSH to see if you can explore other aspects of his good.
2. The system itself decides, unpredictable time/call System.GC ().
Analysis: This answer accounted for about 55%, most of the fresh students can answer this answer, at least not a mistake is it, the follow-up should be broken down in the end is the language of the expression lead to the answer is too general, or itself only such a vague understanding.
3. Can say the new generation, the old generation structure, can propose minor gc/full GC
Analysis: To this level, basically can say that the GC operation has a conceptual understanding, such as read "Deep JVM virtual Machine" and the like. This part is less than 10%.
4. Can explain the trigger condition of minor gc/full GC, the trigger condition of oom, and reduce the strategy of GC tuning.
Analysis: List some of my expected answers: Eden is full of minor GC, the object of ascending to the old age is greater than the old age of the rest of the space full GC, or less than when the Handlepromotionfailure parameter forced full GC , GC and non-GC time consuming more than gctimeratio limit caused by oom, tuning such as through Newratio control of the new generation of the old age ratio, through maxtenuringthreshold control into old age before the number of survival, etc... Can answer that this stage will bring me higher expectations, of course, the interview when normal people will not remember the spelling of each parameter, I wrote this paragraph when I also turned over the manual. The answer to this section is less than 2%.
PS: Add up to less than 100%, is because there are really few directly say do not know, or directly refused to answer = =#
Analyze the second question: "What is the Thing":
1. Objects that are not used.
Analysis: The equivalent of no answer, the question is to ask what the object is "not used objects." accounted for about 30%.
2. An object that is out of scope object/reference count is empty.
Analysis: The 2 answers stood at 60%, a fairly high percentage, and the teacher was taught to teach Java at school. The first answer does not solve my question, how exactly does the GC determine which objects are not in scope? As for the reference count to determine whether the object can be collected, I can add one of the following example to let the interviewer analyze Obj1, OBJ2 will be GC off?
Class c{
public Object x;
}
C obj1, obj2 = new C ();
obj1.x = Obj2;
obj2.x = obj1;
OBJ1, obj2 = null;
3. Search from GC root to search for objects not found.
Analysis: Root object lookup, tag is pretty good, less than 5% people can answer this step, is estimated to be a reference counting way too "deep in the hearts of the public." Basically you can get all the points for this problem.
PS: There are candidates in this question to add strong references, weak references, soft references, phantom reference differences, not the answer I want to ask, but you can add points.
4. cannot be searched from root, and after the first mark, cleanup, there is still no Resurrection object.
Analysis: I look forward to the answer. But it's true that very few interviewers will answer that, so in my mind I answer the 3rd I give all the points.
Finally, a question: "What to Do", the space for this question to play is too big, different times, different collectors of the action is very large.
1. Remove unused objects and free up memory space.
Analysis: With question 2 1th. 40%.
2. Add some instructions such as stopping other threads from executing, running finalize, and so on.
Analysis: At least the problem materialized some, if like answer 1, I can hardly find the topic in the answer to continue to expand, about 40% of the people.
Add a little digression, the interview I most afraid of the answer is "This problem I can not say, but encountered when I surf the internet to make it." Do program development really is not to exercise anise beans "anise" There are several ways, do not memorize I agree, I will not correct grammar, words, but how much you say a thought ah, to directly answer an Internet search, I have no way to get the information can be evaluated candidates, it is difficult to continue to explore the topic from the answer to discuss. It is recommended that you try to answer the areas you are familiar with and discuss, and show them to the interviewer's best side.
3. Can say what the new generation is doing is replication cleanup, from Survivor, to Survivor is what to do, the old age is to mark clean up, Mark clean up after the fragment to do not tidy, copy cleanup and tag cleanup have what advantages and disadvantages.
Analysis: Also read the "Deep JVM virtual machine" Basic can answer this degree, in fact, to this extent I have been more than expected. Also less than 10%.
4. In addition to 3, can also be clear serial, parallel (collation/Not defragment), CMS, such as the role of the collector can be the age, characteristics, advantages and disadvantages, and can explain the control/adjustment of the collector selection method.
Analysis: The 4th with the above 2 questions.
Finally introduce your own background, in a modest listed software company as a platform architect, has 3 years of experience in the interviewer, the main direction is the large-scale enterprise application, participated in a number of billion-level projects in the bottom structure of the work.
Java GC Interview Questions