After reading through this surface, you can also get a Jingdong Offer.

This is a 7000-word long article, the author is a 211 small master, got Jingdong R & D Kong Offer, summed up his school to recruit and get to participate in Jingdong offer face questions and answers, as well as learning, bloggers only a simple format changes.

For a school admissions, it can JVM, network knowledge, JDK source code and other comprehensive understanding so that he did not Beijing East, who Beijing East. He did so, you can.

one side

Interview a long time to answer a little faster, all the issues have carried out a complete answer. In the form of telephone interviews, are based on the general difficulty, do not be nervous, knowledge can be answered.

The main contents include jvm relevant knowledge network (TCP / IP, DNS), JDK source (HashMap, ArrayList, HashTable, etc.)

JVM section

This is part of the main series is the ability to test knowledge points, when the interviewer asked a question, take the issues related to knowledge are listed here (prior to say you can ask if the interviewer requires detailed knowledge about the point).

Reference books: in-depth understanding of the Java virtual machine - Zhou Zhiming book of God! The book of God! The book of God! Recommend brush a few times, all the knowledge in the book by region and JAVA JAVA runtime memory model with two large modules listed thread completely.

Chang examination contents: GC, JAVA thread implementations, volatile the underlying principle, thread-safe, and lock CAS, etc.

JAVA runtime area under 1. speak

Answer: run-time data area as a whole is divided into two types of thread and thread private share.

Thread private include:

  • Program Counter
  • When executing the java method, the counter records the address byte code instructions being executed
  • If you are executing a native method, the counter is empty
  • The region is the only one that will not lead to the area outofmemoryError
  • VM stack
  • Java memory model is a description of the method performed: Each stack frame, which will create a local variable table for storing information, the operand stack, dynamic link, the method exports
  • The local variable table stored compile known basic data types, object references, and returnAddress type (address pointing to a byte code instruction), the local variable table memory space in the compiler determines that, in the same runtime
  • It can lead to two anomalies: stack depth greater than the depth of the thread requests allowed -StackOverflowError virtual machine; virtual machine can not apply sufficient memory -OutOfMemoryError
  • Native method stacks
  • And virtual machine stack is similar, but it is a method for the Native Service

Threads share include:

  • stack
  • java heap is shared by all threads of memory area, created when the virtual machine is powered on, and used to allocate an array of object instances
  • Heap is a garbage collector key management areas, can be divided into the new generation and the old heap years
  • From the perspective of memory allocation, the stack may be divided into a plurality of threads assigned private buffers (Tlab)
  • And size can be controlled by -Xmx -Xms
  • Methods district
  • Used to store information like a virtual machine load, constant, static variables, the time compiler to compile the code and other information
  • Unloading the GC recovered in the region and the constant pool of the type runtime constant pool *
  • Class file constant pool for storing various literal and compile generated reference symbols, this part will be stored in runtime constant pool after the class is loaded
  • Also translated directly references are also on the runtime constant pool constants generated runtime also on the inside

2. simply under the garbage collection mechanism

General idea: to garbage collection, we must first determine whether an object is alive, which leads to the two methods ...

Reference counting and reachability analysis gc roots type reference type twice the marking process garbage collection algorithm memory allocation strategy trigger a garbage collection garbage collector will reclaim method area

Answer: To garbage collection, we must first determine whether the survival of the subject, leads to two methods:

  • Reference counting
  • Thought: setting a reference counter to the object, once the object is not referenced, the counter + 1, referenced by failure counter is -1, any time when the reference counter is 0, the object can be recovered
  • Java does not apply reason: the object can not be resolved mutually circulation problems cited
  •  
  • Reachability analysis
  • Virtual Machine stack (local variable table stack frame) referenced objects
  • Method static property class object referenced by region
  • The method of constant reference object region
  • Native method stack JNI (Native Method) referenced objects
  • With GC Roots as a starting point, a starting point from which to start the search down through the path is called the chain of references. If an object has no references to the chain between GC Roots, the target is unreachable.
  • You may have a GC Roots object
  •  
  • Reachability analysis, life-cycle type of object reference object will have an impact, JAVA there are several types of references:
  • Strong Quote: As long as the reference is still valid, GC will not be recovered
  • Soft references: not enough memory space recovered, recovered before memory overflow occurs, class implemented SoftReference
  • Weak references: weak reference objects associated only survive until the next Gc collection, implemented WeakReference class
  • False quote: Failed to get through the phantom reference object instance, does not have an impact on the survival time of the object, the only purpose: when the object is to collect Gc, receive a notification. Implemented PhantomReference class
  •  

A real object is not available, go through two labeling process:

  • First reachability analysis, screening and GC Roots useless objects referenced chain, for the first time mark
  • After the first mark, and then conduct a screening filter criteria is whether it is necessary to perform the finalize () method. If the object has not override finalize () method, or finalize () Has been called jvm, it is not necessary to perform, GC will reclaim the object
  • If necessary executed, the object will be put into F-Queue, open the jvm to execute it (but not necessarily wait finalize finished) a low priority thread.
  • Finalize () is the last chance to save themselves the object, if the object finalize () in reference to rejoin the chain, then it will be removed from the object to be recovered in the collection. Other objects will mark the second time, recovered

Garbage collection algorithm in JAVA are:

  • Mark - Clear (Mark-Sweep)
  • Two phases: mark, Clear
  • Cons: not high efficiency two-stage; easy to produce large amounts of memory fragmentation
  •  
  • Copy (Copying)
  • The memory is divided into two identical size, when a memory runs out, and put the copy onto another one available object, the used disposable clean out a
  • Disadvantages: half wasted memory
  •  
  • Mark - finishing (Mark-Compact)
  • After labeling, so that all surviving objects to the end, then clean out the direct memory other than the end border
  •  
  • Generational collection
  • The heap is divided into the old and the new generation's
  • The use of the new generation of replication algorithm
  • The new generation memory is divided into a large area and two small Eden Survivor; and each use a Survivor Eden, Eden and the recovery of the copy live objects to Survivor ratio (the HotSpot another Survivor Eden: Survivor = 8: 1)
  • Old's use of mark - to clean up or mark - finishing
  •  

GC also involves the trigger memory allocation rules: (target mainly distributed in Eden, if the thread-local allocation buffer start, priority will be allocated on TLAB)

  • Objects priority allocation in Eden
  • When there is not enough space for Eden district will launch a Minor GC
  • Large objects directly into the old year
  • A typical large objects is a very long strings and arrays
  • Long-term survival of the object enters years old
  • Each object age counter that, every time GC, plus a counter value when it reaches a certain extent (default 15), will enter the old year
  • Age threshold may parameter -XX: MaxTenuringThreshold provided
  • Determine the age of objects
  • The sum of the sizes of all objects of the same age Survivor Survivor space greater than half the space, age greater than or equal to the target can be directly into old age years, requirements need to wait until the age MaxTenuringThreshold
  • Space allocation guarantees
  • Before the occurrence of Minor GC, jvm will check whether old's maximum available contiguous space is greater than all the objects in the new generation of total space, if so, then it is safe Minor GC
  • If not greater than, jvm will see HandlePromotionFailure whether to allow a security failure, if allowed to, will be replaced by a Full GC
  • If allowed to guarantee failure, check whether old's maximum available contiguous space larger than the previous years was promoted to the average size of old objects, if so, then try to Minor GC; if less than, will have to be changed Full GC
  •  

Garbage collector:

  • Serial (serial collector)
  • Features: single-threaded, stop the world, using replication algorithm
  • Application scenarios: jvm default mode in the new generation of collectors Client
  • Pros: Simple and efficient
  •  
  • ParNew
  • Features: It is a multi-threaded version of the Serial, using replication algorithm
  • Scenario: commonly used in the new generation of collectors under Server mode, works with CMS
  •  
  • Parallel Scavenge
  • Features: parallel multithreaded collector using replication algorithm, a certain priority, an adaptive regulation strategy
  • Scenario: require large throughput time
  •  
  • SerialOld
  • Features: Serial old's version, single-threaded, using the mark - Collation Algorithm
  •  
  • Parallel Old
  • Parallel Scavenge old's version, multi-threaded, Mark - Collation Algorithm
  •  
  • CMS
  • Sensitive to CPU resources
  • We can not handle floating garbage (concurrent cleared, the user thread is still running, the garbage generated at this time floating garbage)
  • A large amount of space debris
  • Initial labels: stop the world GC Roots mark object can be directly linked to the
  • Concurrent mark: be GC Roots Tracing
  • Mark recorded during the concurrent mark correction due to the continued operation of the user program which led to marked changes in that part of the generated object; stop the world: re-mark
  • Concurrent Clear: Clear Object
  • Features: pause in the shortest recovery time objective, using the mark - sweep algorithm
  • process:
  • Advantages: concurrent collection, low pause
  • Disadvantages:
  •  
  • G1
  • Initial labels: stop the world GC Roots mark object can be directly linked to the
  • Concurrent mark: reachability analysis
  • The final mark: amend that part of the mark recorded during the concurrent mark because the user program continues to operate and generate leads to marked changes
  • Filter Recycling: recovery stage first screening of recovery value and cost of each Region to sort, to develop recycling programs according to user desired GC pause time
  • Parallel and Concurrent
  • Generational collection
  • Spatial Integration: from the overall look is based on the "mark - finishing" from the local (between two region) to see is based on the "copy".
  • Predictable pause: the user may explicitly specify a time segments of length M in milliseconds, consumed in the garbage collection may not exceed N milliseconds.
  • Features: for the server application to divide the entire heap of the same size region.
  • Implementation process:
  • GC adaptive strategy Parallel Scavenge collector has a parameter -XX: + UseAdaptiveSizePolicy. When this parameter is open, you do not need to manually specify the size of the proportion of the new generation, Eden and Survivor areas, promotion of old age and other details of the object's parameters, and virtual machine performance monitoring information collected in accordance with the operation of the current system, dynamically adjust these parameters to provide the most suitable dwell time or the maximum throughput, this adjustment is called adaptive adjustment strategy GC (GC Ergonomics).

(Garbage collector section highlight some of CMS and G1)

Finally mention will recycle method area:

  • Recovery of the permanent generation of two parts: a constant and useless waste classes
  • Recovery and recycling of waste constants similar objects
  • Useless class must meet three conditions
  • Examples of all objects of that class have been recovered
  • ClassLoader class loads have been recovered
  • Class object class is not referenced anywhere, can not be accessed by means of reflection class anywhere
  •  

The above knowledge in the brush a few times after you book, the brain form the corresponding knowledge network to say it is very comprehensive.

The network part

Network knowledge is very important in the interview, especially TCP, DNS, HTTP and other knowledge points.

The part of my reference books are: graphic HTTP, graphic TCP / IP (For developers, the two books explain in terms of the network should be enough), and related blog.

Responding to such problems, the question remains diffused from the interviewer mentioned, the problems related to their own throw to tell (when asked if the interviewer can be thrown about the need for a detailed explanation)

1. talk about the TCP three-way handshake

For this problem, you can associate a direct TCP broke four times to answer. If the spot interview, you can draw the client and server TCP state sequence on paper.

Then it can be thrown related issues to answer, such as:

Why not use two-way handshake, SYN half-connection attack, the TIME WAIT too many how to do, why, when the connection is three-way handshake, closing time is 4 times to break up, why the TIME WAIT state to go through 2MSL (maximum segment survive time) to get back to CLOSE status and so on (these issues in the internet have to explain, not go into details here).

2. TCP and UDP difference between the (very common problem):

  • TCP connection-oriented (e.g., dial-up connection is established first call) the UDP is connectionless, i.e. without establishing a connection before sending data
  • TCP provides reliable service. In other words, the data transfer connection of TCP, error-free, not lost, not repeat, and arrive out of order; UDP best effort, that does not guarantee reliable delivery
  • TCP byte stream and, in fact, the TCP byte stream data as a series of unstructured; for the UDP packets is
  • UDP no congestion control, and therefore does not cause congestion source host of the network is to reduce the transmission rate (useful for real-time applications such as IP telephony, real-time video conferencing, etc.)
  • Each TCP connection can only point to point; UDP support one to one, one to many, many-to-many communication and interaction
  • TCP header overhead of 20 bytes; small UDP header overhead, only 8 bytes
  • Logical communication channels are TCP reliable full-duplex channel, UDP is unreliable channel

3. speaking under the principle of ARP

  • By means of an ARP request and an ARP response to determine the target's MAC address from the target address Ip
  • Principle: transmitting by broadcast ARP request, the host address match Ip receives the request, and then added to the own MAC address returns the ARP response packet to the source host. To MAC address cache to avoid consuming network traffic
  • Each host will establish a list of their ARP ARP buffer, the correspondence of Ip address and MAC address
  • When a source host to send data, first checks whether the MAC address corresponding to the address of the target host Ip ARP list, if any, sent directly, if not, sending ARP packets to all hosts on the network segment, the data the contents package including: Ip source address, source MAC address, destination host address Ip
  • When all of the hosts of this network receives the ARP packets, first checks whether the address bag Ip is Ip own address, if this is not discarded if it is first removed from the packet source host the MAC address and IP write into its ARP list, if there is already, the covering; ARP response packet and then writes the own MAC address, the source host to tell its own MAC address
  • When the source host receives the ARP response packet, the destination host IP and MAC address written ARP table. If the source host has not received ARP response, the ARP query failed
  • (ARP request broadcast transmission, unicast ARP response) At this point, they can add free ARP ARP attacks and related knowledge (self-search)

JDK source code section

This part is their usual accumulation, see related blog can follow the source. Often test the contents String, Collections Framework, foreach (Iterator and fail-fast mechanism) and so on.

1. HashMap understand it, say something

Here not explained in detail, and the general idea is jdk7 the principle and the difference jdk8 (Key data structure implementation, the memory cell to change from Entry Node, the load factor, when expansion, jdk1.8 expansion of specific implementations ), the difference between HashMap and HashTable, the relationship HahsMap HashSet and so on. To combine the source said.

ArrayList understand it, say something

Focus is on the underlying implementation, expansion mechanism, and the underlying LinkedList implementation; the difference between them. To combine source says

Two faces

Interview not long to answer some individual false bottom. The main study of the breadth and extent of the love of technical knowledge, as well as familiarity with the project done. Again, answer questions honestly, that is not will not, but if asked would pretend to fall next question, then it is gone.

Internship related problems projects

Everyone's project is different, just to name a few questions

The project is how to prevent sql injection

Answer: using a MyBatis, sql statement using the # {}, {#} denotes a placeholder, # {} may be implemented by the placeholder preparedStatement setting value, there is a pre-compiled JDBC process can effectively prevent sql injection, do not try {} $, it is a mosaic character, for splicing sql string.

Project you do redis cache related configuration section (resume write)

  • Section analysis: @Aspect
  • Section: redis before querying the first query, if the query can not, then check the database, the data is saved to get in redis
  • Target method: query the database
  • Front: check first before querying redis
  • Rear: found from the database content into the redis
  • Positioning around the notification section notify: @Around

Then he asked the realization of the principle of aop (jdk dynamic proxy and bytecode enhancement cglib, say in answer to the underlying source code)

Like what technology

A: distributed, although the internship he was doing the business background and does not involve a lot of distributed content, but will often understand some distributed from colleagues feel very interesting technology

We have learned what a distributed technology

A: The reverse proxy and load balancing nginx, and high availability of keepalived + nginx; redis-memory database and its basic data types and persistent manner; for doing registry dubbo zookeeper services and governance; to prevent users single sign-on login repeat; distributed file storage system fastdfs; freemarker static pages processed; and solr for searching (due in part to some of the technology they will use only, do not know the bottom, so that the hesitant, it is not emboldened, in fact, not necessary, then say it openly explain their understanding of the extent to)

Feel what areas lacking

Answer: spring source not know much about the other aspects of linux somewhat weak, it is to supplement the relevant knowledge. (You can add your own book which is currently looking at)

jdk9 know what

Answer: not very clear, not understanding (inner state: FML, when jdk9 out) (This problem can be well aware of the degree of love for technology job seekers, who are able to pay more attention to the development direction of technology, iterative version this aspect can focus on some high-quality public numbers: as Hollis)

Why Internet companies want to come

A: It may affect internship is the first of it, the interviewer: what else? Me: I do not know, it is that Internet companies want (wanted to kill himself after the finish)

HR surface

hr face important is faith, there is good to go express themselves about the company and the company's

There are a few offer

A: 1, but it has been refused a

Why refuse a

A: Because it is not the Internet companies

Why do you want the Internet company's development

A: The high wage is one thing, but in Internet companies in general can reach more quickly to new technology

Why want Jingdong

A: Jingdong is because I am concerned about the company for a long time, from the fall of Jingdong doing trick video broadcast for the first time began to take notice. First is an Internet company Jingdong, Jingdong followed by development in recent years for all to see, and Jingdong is in transition to technology companies believe they can learn a lot.

Do you have any shortcomings

A: Do you like to relieve the pressure when pressure by eating, but also what it is to lose weight a lot of trouble

anything else

A: I like to stay up late

anything else

A: emmmm, Oh, I can not remember (in fact, about the pros and cons of the issue should take summarize, or ask then easily rip off force) there are a few problems do not remember, probably an intern for their views and colleagues when it is not the same as how to solve. For this problem, the best give an actual example.

to sum up

In fact, most of the surface via the Internet have made it very clear that we must form their own tree of knowledge, if only want to see through to the surface through an interview, would be difficult. Their usual must accumulate knowledge, the knowledge points classification record, the initiative say the solution to the problems relating to the interviewer's question in the interview process can be a plus, knowledge of the series to reflect their own ability.

Now a lot of Java friends are job hopping, in order to solve the urgent needs of everyone, specifically for bloggers we have compiled a list of Java-related interview questions, you can exchange Jiaru Bo skirt Lord: 777-584-112 get.

 

No one will hate and who refused to seriously prepare for the interview, so do not think the interview is the need to use a "makeup" you go to "good faith" in the face.

Guess you like

Origin blog.csdn.net/qq_36860032/article/details/90413577