Headline face questions exercises


The difference between a == b and a.equals (b) of (because they can not, so surface finish search, I found that there should be a JAVA questions, I learn that C ++)

equals function is a member of the Object class, all classes in Java inherit the Object, in the class can override the equals method. In the object using a == b, if no override euqals method, it is determined whether the address represents the same.

The difference between && &

& It is logical AND operation, with &&

What is polymorphic

Base class pointer to the derived class, the derived class calls the base class virtual function override.

Description of the heap and stack difference

In the C ++ language, much larger than the heap stack space.

Heap application out of memory, you need to manually release.

Enter the url to the page from fully loaded, we have gone through what process

DNS name resolution, TCP connection is established, the HTTP request, response HTTP request, parse HTTP content.

Use a SQL statement to query the student in every subject is greater than 80 points

Quality testing of paper cups

Good quality cup measuring several divided by the number in the glass.

Extracted with 5 liters of 3 liters and 6 liters of water kettle
1, five liters pots filled;
2, was poured into six liters pots (full, there are 5 liters);
3, then five liters pots filled;
4, six liters was poured into the pot, the pot is full six liters, five liters pots left 4 l;
5, six liters pot emptied,
6, five liters pot remaining four liters of water was poured into six liters pot, jug case six liters four liters
7, five liters pot filled;
8, into the pot filled with six liters, this time five liters jug with three liters of water, is completed.

 

 

A programming problem, more than half the number of arrays of numbers that appear

Moore voting method

Organizational activities, people often late, how do (really do not know Zaban)

Consider an m * n squares, went to the lower right corner from the top left, or right can only go down, how many kinds of moves (originally thought it was a programmed title, said dynamic programming, but the interviewer seems to want He said a general formula, and did not think, if someone would, you can respond to it)

Permutations

 

 

Project Issues

socket interface functions which can be called

 

Describe time_wait state and state close_wait

How to avoid time_wait state and state close_wait

How 1. time_wait state produce? 
From the above chart change, first call the close () the party initiating active close, after sending the final ACK will enter the state time_wait, also said will return to the initial state after the sender will remain 2MSL time. MSL is worth a packet in the network maximum lifetime. This result is generated such that the TCP connection during the connection waiting 2MSL, define the connection four-tuple (IP address and port of the client, the server IP address and port number) can not be used.

 

The reason 2.time_wait state generated

1) In order to achieve reliable release full-duplex TCP connection

2) For older data packets in the network due to expire and disappear

 

How to avoid state 3.time_wait

First, the server can be set to notify the kernel SO_REUSEADDR socket option, if the port is busy, but you can reuse a TCP connection port is located in the TIME_WAIT state. In a scene that is very useful, if you want to reboot the server program stops immediately, while the new socket still want to use the same port, this time SO_REUSEADDR option can avoid TIME_WAIT state.
 

 

epoll advantage

When the IO event occurs, epoll directly know which one socket IO event occurs while eliminating the need to repeatedly copy the kernel array.

Level trigger and edge trigger, under what circumstances the use of

Level_triggered (level trigger): When the monitored file descriptor can read and write events, epoll_wait () will notify the handler to read and write. If this is not the time to finish reading and writing of data all at once (such as read and write buffer is too small), then the next call epoll_wait (), it will also notify you have not finished reading and writing on file descriptor continue to read and write Of course, if you have not read and write, it would have been to inform you! ! ! If there are a large number of ready file descriptors you do not need to read and write, and every time they return, it will greatly reduce the processing efficiency ready to retrieve a file descriptor you care about! ! !

Edge_triggered (edge-triggered): When the monitored file descriptor can read and write events, epoll_wait () will notify the handler to read and write. If this is not done the reading and writing all the data (such as read and write buffer is too small), then the next call epoll_wait (), it will not inform you, that is, it will notify you once, until the file descriptor The second event may appear to read and write will inform you! ! ! This model is higher than the trigger level of efficiency, the system will not be flooded with a large number of file descriptors ready you do not care! ! !

Epoll kernel space whether open

epoll a data structure:

1.mmap:

epoll by kernel and user space mmap the same memory. The mmap an address of a user address space and kernel space mapped to the same physical memory address, so that this physical memory kernel and user are visible, reducing the exchange of data between user and kernel mode. Epoll kernel can see the monitor handle and more efficient.

2. The red-black tree:

Red-black tree will store all epoll socket is listening. mmap out of the memory employed epoll red-black tree to store all of the socket, when added or removed when a socket (epoll_ctl), red-black trees are treated, the time complexity of O (logN)

3.rdlist list:

Adding a node within the incoming event by epoll_ctl function will be placed in the red-black tree. When the event came in added time, the event will be the corresponding device (NIC) drivers to establish relations callback, when the corresponding event occurs, will call the callback function (ep_poll_callbac), this is actually a callback function to add this event to rdlist this doubly linked list. Once an event occurs, epoll will add the event to the doubly linked list. When you call epoll_wait, epoll_wait only need to check if there is an event registration rdlist doubly linked list.

Dns resolution of specific process

① to hosts running DNS client is our client PC or mobile phone running the DNS client
② browser received the url extracted domain name field, is the host name to access, such as

And the DNS host name passed to the client application
③DNS client sends a query message to the DNS server, the packet contains want to access the host name field (including some of the middle row, and distributed DNS cache query the work of the cluster)
④ the DNS client eventually will receive a reply message, which contains the host name corresponding to the IP address
⑤ Once the browser receives the IP address from DNS, it is possible to locate the IP address HTTP server initiates a TCP connection

Zombie process

Zombie process is ended when the child than the parent first, and the parent has not recovered the child, the child process to release resources occupied, then the child will become a zombie process. If the parent process exits first, the child was taken over by init, after the child process exits init will recover their occupied resources

find command

Linux find command to find the file in the specified directory. Any string parameters located before will be considered directory name you want to find. If you use this command does not set any parameters, the find command will find subdirectories and files in the current directory. And will look into all the subdirectories and files are displayed.

grammar

find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \;

The difference between get and post

1, url Visibility:

get, url parameters visible;

post, url parameter is not visible

2, the data transmission:

get, splicing parameters passed url;

post, body parameter transmitted through the body

3, the cache of:

get request can be cached

post requests can not be cached

4, the back page of reaction

Get back when the page is requested, does not have an impact

When the requested page back post, will resubmit the request

5, the size of data transmission

Usually get the transmission data size does not exceed 2k-4k (depending on the browser, is not the same limitation, but little difference)

post requests the transmission data according to the size php.ini configuration file setting, it may be infinite.

6, security

This is the worst analysis, in principle, certainly better than get security post, after all, is not visible url transmission parameters, but also can not stop some people that get caught in the free play of nothing. Safety personally think it is not much different, the gentleman is not anti-anti-villain is the truth. To encrypt the parameters passed, in fact, they are the same.

 

dns easily intercepted reason

 

Common sorting algorithm and its time complexity

 

Tell us about the process of heap sort

 

A programming problem, the use of a linked list insertion sort

Guess you like

Origin blog.csdn.net/wwxy1995/article/details/94393569