One side given by Tencent boss

       After two interviews, my heart is no longer floating, and I have to pay attention to the problems I knew before. There is no opportunistic approach to learning technology. Reading books should be read in conjunction with this code, or it will be endorsed again.

The interview questions are as follows:

1. What is the recycling strategy of Java? How to judge the recyclable status? What are the disadvantages of reference counting?

 

    answer address

 

2. Which one of "abc".equals(a) and a.equals("abc") is generally used in a project? Why?

 

     The first one is generally used, in order to prevent null pointer exceptions

    Detailed explanation

 

3. How does IO achieve read and write without locking?

   

   Using the Producer Consumer Pattern

   Producer Consumer Details Address

 

 

4. ① Now give you a memory space of 65535, one for continuous reading and one for continuous writing, how can it run smoothly?

      Or use the producer-consumer model;

     ② Now it needs to continue to run for N years, and then how to do it?

      Use the least-used page replacement algorithm;

     

 

5. 65535Bytes is a data buffer. One thread serializes the data and writes it, and the other deserializes and parses it. How to deal with the out-of-bounds problem?

6. Now there is a scenario, the writing thread has written to 65534, and the reading thread has read 65500. It is about to cross the boundary. What should I do?

 

       TCP sticky unpacking

       Ring buffer to solve the sticky packet problem

 

7. What is the difference between stacks?

 

       Answer details

 

8. You new an object Xiaoming, and an int value (age) is stored in the object. Is the memory of this age on the heap or the stack?

 

         pile on

 

9. You created a structure with a HashMap in the structure. Is this HashMap on the heap or the stack?

 

         pile on

 

10. What is the difference between Thread and Runnable? Which do you prefer to use at work?

 

       We prefer to use the second one in engineering, because java is a single-inheritance language, but in order to make up for this deficiency, the java language designers have added functions that can implement multiple interfaces, so we prefer to use the second kind.

       Three ways to create threads

 

11. Try catch finally, if the try returns, is the finally still executed?

       

       finally can be executed;

       Code Test Details

      

 

12. The principle of red-black tree, and write red-black tree?

 

13. ① In 100M memory, sort 1 billion QQ numbers?

        ②Download the video while watching it. When we directly pull the progress bar to N minutes, when we download the video again, we don’t want the downloaded data in the previous file to be wasted. What should we do?

 

        bitmap algorithm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326490004&siteId=291194637