Because there are many students who have just taken the introductory test , These two days I took the time to sort out a copy of the interview questions and answers for the internship , To tell you the truth, this topic is really simple , If you come across such interview questions in a large factory , I'm lucky . You can also test yourself first , See if you can answer .
If you think some knowledge points are just understanding , But if you can't say it when you ask , It is suggested to supplement the foundation before the interview . My high school math teacher's mantra is ：“ not completely understand , I just don't understand .”
HTTP The data transmitted by the protocol is unencrypted , Plaintext , Therefore use HTTP Protocol transmission of private information is not secure .
In order to ensure that private data can be encrypted , So using SSL Protocol is used to HTTP The data transmitted by the protocol is encrypted , namely HTTPS;
HTTPS Agreement is HTTP + SSL The protocol is built for encrypted transmission 、 Network protocol for identity authentication , Than HTTP More secure .
HTTP and HTTPS The main differences between the two are ：
HTTPS Need to CA Apply for a certificate , Generally, there are fewer free certificates , Therefore, a certain cost is required ;
HTTP Hypertext transfer information , The message is transmitted in clear text ;HTTPS It's safe SSL Encrypted transport protocol ;
HTTP and HTTPS It USES a completely different connection ,HTTP By default 80 port , and HTTPS By default 443 port ;
HTTP The connection is simple , It's stateless ; and HTTPS yes SSL + HTTP The protocol is built for encrypted transmission 、 Network protocol for identity authentication , Than HTTP Security agreement ;
HTTP The status codes are roughly classified as follows ：
Several common status codes ：
Client should continue to send request . This temporary response is used to inform the client that some of its requests have been received by the server , And has not been rejected . The client should continue to send the rest of the request , Or if the request has been completed , Ignore this response . The server must send a final response to the client after the request completes .
101 -（Switching Protocols）：
Handover protocol . Server switches protocol according to client's request . Can only switch to a more advanced protocol , for example , Switch to HTTP New version agreement for .
200 -（OK）： Request succeeded , The response header or data body that the request expects will be returned with this response .
201 -（Created）： Created . Successfully requested and created a new resource .
301 -（Moved Permanently）：
A permanent move . The requested resource has been permanently moved to the new URI, The return information will include the new URI, Browser will be automatically directed to new URI. Any new request in the future should use the new URI Instead of .
Temporary movement . And 301 similar . But resources are only temporarily moved . The client should continue to use the original URI.
304 -（Not Modified）：
not changed . The requested resource has not been modified , When the server returns this status code , No resources will be returned . Clients usually cache accessed resources , Indicate by providing a header that the client wants to return only resources modified after a specified date .
400 -（Bad Request）： Syntax error in client request , Server does not understand .
403 -（Forbidden）： The server understands the request from the requesting client , But refused to execute the request .
404 -（Not Found）： The server could not find the resource at the request of the client （ Webpage ）. By this code , Website designer can set " The resource you requested could not be found " Personal page of .
500 -（Internal Server Error）： Server internal error , Unable to complete request .
502 -（Bad Gateway）： Server acting as gateway or proxy , An invalid request was received from the remote server .
503 -（Service Unavailable）： Due to overload or system maintenance , The server is temporarily unable to process the client's request . The length of the delay can be included in the server's Retry-After In header information .
504 -（Gateway Time-out）： Server acting as gateway or proxy , Request not obtained from remote server in time .
In most cases, operators HTTP hijacked .
When we use HTTP When requesting a web page , Network operators will insert well-designed network data messages into the normal data flow , Let client （ Usually a browser ） Exhibition “ error ” The data of , Usually some pop ups , Advertising or direct display of the content of a website .
HTTP Implementation principle of hijacking
The user's browser accesses the web page , send out HTTP request , The operator's router will be in TCP In the link , Filter out HTTP request , And identify .
And then , Before the visited website responds normally , Redirect the request initiated by the browser , Then discard the normal response packet of the visited website ;
Or the operator's router receives a normal response from the website , Then respond to HTML code “ Machining modification ”, such as ： Added an annoying ad , And then put the modified HTML The code is thrown to the browser for rendering .（ In fact, it is similar to the principle of intermediary agency ）
It can be seen from the above principle that , If it needs to be done HTTP hijacked , First, you need to mark ： If it is HTTP agreement , So hijacking , Otherwise, no hijacking .
A process is the smallest unit of resource allocation , A thread is the smallest unit of program execution .
Process has its own independent address space , Every time a process is started , The system will allocate address space for it , Create data tables to maintain code snippets 、 Stack and data segments , This operation is very expensive .
Threads share the data in the process , Use the same address space , therefore CPU Switching a thread costs much less than a process , At the same time, the cost of creating a thread is also much less than that of a process .
Easier communication between threads , Threads sharing global variables in the same process 、 Data such as static variables . And the communication between processes needs to be in the form of communication （IPC) Conduct . But how to deal with synchronization and mutual exclusion is the difficulty of writing multithreaded programs .
But multiprocessing is more robust , A multithreaded program only needs one thread to die , The whole process is dead , And the death of one process does not affect the other , Because the process has its own address space .
Locking mechanism ： Including mutexes 、 Condition variables, 、 Read-write lock .
The mutex ： Provides an exclusive way to prevent concurrent modification of data structures .
Read-write lock ： Allow multiple threads to read shared data at the same time , And write operations are mutually exclusive .
Condition variables, ： Processes can be blocked atomically , Until a particular condition is true . The condition is tested under the protection of the mutex . Conditional variables are always used with mutexes .
Semaphore mechanism (Semaphore)： Including anonymous thread semaphores and named thread semaphores .
Signaling mechanism (Signal)： Similar to signal processing between processes .
The communication between threads is mainly used for thread synchronization , So threads have no communication mechanism for data exchange like in process communication .
JAVA There are four main ways to implement multithreading ：
Inherit Thread class ;
Realization Runnable Interface ;
Realization Callable Interface by FutureTask Wrapper to create Thread Threads ;
Use ExecutorService、Callable、Future Implement multiple threads that return results .
Neither of the first two methods returns a value after the thread completes its execution , The last two are with return values .
The title is not very clear , Here are some test points , You can expand it .
Positioning test ：
Confirm whether the network environment is normal
Grab the packet and see the interface return
Check the server log
HTTP： application layer
TCP： Transport layer
IP： The network layer
What this question should examine is Java Knowledge points of ：
Class differences ：
sleep() come from Thread.wait() come from Object.
Release the lock ：
sleep() No release lock ;wait() Release the lock .
Use different ：
sleep() Time will be restored automatically ;wait() have access to notify() / notifyAll() Wake up directly .
The scope of use is different ：
sleep Can be used in any code block .wait Must be executed in a synchronization method or synchronization code block .
Life cycle ：
When a thread calls wait() perhaps join when , Threads will enter waiting state , When calling notify or notifyAll when , perhaps join After the thread execution of , Will enter runnable state . When a thread calls sleep(time), perhaps wait(time) when , Get into timed waiting state .
The shallow copy just copies the reference address of the object , Two objects point to the same memory address , So modify any of these values , Another value will change with it , This is a shallow copy （ example ：assign()）
Deep copy is to copy objects and values , Two objects modify any of the values and the other does not change , This is the deep copy .（ example ：JSON.parse() and JSON.stringify(), But this method can't copy function types ）
JDK：JAVA Development kit
JRE：JAVA Running environment
The title is sword finger offer（57） The original title is .
leetcode link ：
That's the end of the first part
If you're also preparing for an interview , Then I wish you a smooth landing as soon as possible ！
These materials , For doing 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ！ Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills .
Pay attention to my WeChat official account ：【 Programmer two black 】 Free access ~
My learning exchange group ：642830685 There are technical bulls in the group to share with each other ~
If my blog helps you 、 If you like my blog content , please “ give the thumbs-up ” “ Comment on ” “ Collection ” One button, three links ！