Supplementary Java interview notes

Supplementary Java interview notes

 

Background : This is part of the problem encountered in the interview two days are scattered in front of two abstracts in here to do some other record for a rainy day!

 

First, talk about your understanding of SpringBoot of?

SpringBoot Introduction :
SpringBoot is a frame, its purpose is to simplify the application of the building and the initialization Spring development; The framework uses a particular manner be configured so that the developer does not need to customize the configuration of the template; it can Spring automatically configure the various components, the code generation is not dependent configuration file and XML.

I understand SpringBoot of:

SpringBoot is the starting point of micro-services framework, he simplifies the configuration, deployment and monitoring process; it is the default configuration use a lot of framework, like maven incorporates all the jar packages, SpringBoot integrate a lot of framework, while other Spring combined to form technology with SpringBoot frame, thereby simplifying the development process and to build Spring applications.

Second, talk about your understanding and use of the Java container?

Container interfaces:

1, Collection Interface;

2, Map interface stored key-value pair, the value of the Map may be a container;

3, Iterator interface.

Sub-interface:

1, List, ordered repeatable indexing parameters can be added in the process;

2, Set, without non-repeatable, random and therefore can not index the operation target;

3, ListIterator, Iterator for List, List is a two-way table, thus increasing the number of new methods on Iterator, allow traverse the List in either direction

4, SortedMap, orderly;

5, SortedSet, mainly for sorting operations, implementation subclass subclass are sorted such interfaces;

DETAILED container classes:

1、Collection:ArrayList,LinkedList,Vector,Stack,TreeSet,HashSet,LinkedHashSet

2、Map:HashMap,LinkedHashMap,WeakHashMap,TreeMap,HashTable,IdentityHashTable

Common container classes:

1, ArrayList and LinkedList (both non-synchronized, thread-safety issues to consider when multi-threaded), Vector (synchronous), Stack

1) List interface supports access by a method of indexing elements, modify slow fast random access ArrayList, LinkedList modified fast random access slow, Vector Thus to achieve the synchronization slower than ArrayList;

2) LinkedList bidirectional linked list implementation, LinkedList additional get, remove and insert method in the first LinkedList or tail, these operations are the LinkedList may be used as a stack (Stack), a queue (Queue) or double-ended queue (the deque);

3) ArrayList no definition of growth algorithm, when a large number of elements need to insert, you can call ensureCapacity add methods to improve efficiency;

4) Vector is similar to ArrayList, but it is synchronized, multi-thread safe (Another point difference is the default when half growth expansion ArrayList, Vector doubled), whether it is single-threaded or multi-threaded, Vector slower than ArrayList;

5) Stack inherited from Vector, to implement a LIFO stack;

6) If you need to synchronize you can call synchronizedList method Collections utility class.

2, HashMap (asynchronous), HashTable (thread-safe), TreeMap, WeakHashMap

1) HashTable and HashMap difference:

a.HashTable inherited from the Dictionary class, inherited from HashMap AbstractMap class, but they have achieved Map Interface;

Synchronize method b.HashTable is, while the method in the HashMap Synchronize the non-default;

In c.HashTable, key value, and null values ​​are not allowed; in the HashMap, as null key, only one such key, there may be one or more keys corresponding to null;

d.HashTable object directly hashCode, and HashMap recalculated hash value.

2) WeakHashMap is an improved HashMap, the implementation of its key "weak reference", WeakHashMap use the element of reference rather than value as a key, that is to be found in the relevant case reference the same (a == b) of the value, another key is not referenced outside, then the key can be recovered the GC;

3) TreeMap red-black tree is implemented based on such an interface ensures SortedMap mapping keywords arranged in ascending order, depending on the method of construction, may be ordered according to the natural order based keys.

Three, Http & Https difference?

HTTP data transmission protocol is unencrypted, plain text is therefore transmitted using the HTTP protocol is insecure private information, in order to ensure the privacy of data transmission can be encrypted, so designed Netscape SSL (Secure Sockets Layer) protocol with HTTP protocol for data transmission is encrypted, thus was born HTTPS. Fourth, simple terms, HTTPS protocol is constructed from SSL + HTTP protocol can be encrypted transmission, network authentication protocol than http protocol security.

Four, Http connection is long, or short connection, the length of the connection?

在HTTP/1.0中,默认使用的是短连接;But从HTTP/1.1起,默认使用的是长连接。
短连接:
HTTP短连接,也称非持久连接,客户端和服务器进行一次HTTP请求/响应后,就关闭连接;下一次的HTTP请求/响应就需要重新建立连接。在HTTP/1.0中,默认使用的是短连接。
长连接:
HTTP长连接,也称持久连接,客户端和服务器建立一次连接后,可以才这条连接上进行多次请求/响应操作;持久连接可以设置保活时间(keep-alive),也可以不设置。从HTTP/1.1起,默认使用的是长连接。
使用长连接的HTTP协议,会在响应消息报文段加入如下字段: Connection:keep-alive ,这个字段是让一个TCP连接更持久一些。

五、http与Tcp的关系?

1、TCP连接
手机能够使用联网功能是因为手机底层实现了TCP/IP协议,可以使手机终端通过无线网络建立TCP连接;TCP协议可以对上层网络提供接口,使上层网络数据的传输建立在“无差别”的网络之上;
建立起一个TCP连接需要经过“三次握手”:
第一次握手:客户端发送syn包(syn=j)到服务器,并进入SYN_SEND状态,等待服务器确认;
第二次握手:服务器收到syn包,必须确认客户的SYN(ack=j+1),同时自己也发送一个SYN包(syn=k),即SYN+ACK包,此时服务器进入SYN_RECV状态;
第三次握手:客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1),此包发送完毕,客户端和服务器进入ESTABLISHED状态,完成三次握手。
握手过程中传送的包里不包含数据,三次握手完毕后,客户端与服务器才正式开始传送数据。理想状态下,TCP连接一旦建立,在通信双方中的任何一方主动关闭连 接之前,TCP 连接都将被一直保持下去;断开连接时服务器和客户端均可以主动发起断开TCP连接的请求,断开过程需要经过“四次握手”(过程就是服务器和客户端交互,最终确定断开)。
2、HTTP连接
HTTP协议即超文本传送协议(Hypertext Transfer Protocol ),是Web联网的基础,也是手机联网常用的协议之一,HTTP协议是建立在TCP协议之上的一种应用;
HTTP连接最显著的特点是客户端发送的每次请求都需要服务器回送响应,在请求结束后,会主动释放连接,从建立连接到关闭连接的过程称为“一次连接”;
1)在HTTP 1.0中,客户端的每次请求都要求建立一次单独的连接,在处理完本次请求后,就自动释放连接;
2)在HTTP 1.1中则可以在一次连接中处理多个请求,并且多个请求可以重叠进行,不需要等待一个请求结束后再发送下一个请求;
由于HTTP在每次请求结束后都会主动释放连接,因此HTTP连接是一种“短连接”,要保持客户端程序的在线状态,需要不断地向服务器发起连接请求。通常的 做法是即时不需要获得任何数据,客户端也保持每隔一段固定的时间向服务器发送一次“保持连接”的请求,服务器在收到该请求后对客户端进行回复,表明知道客 户端“在线”;若服务器长时间无法收到客户端的请求,则认为客户端“下线”,若客户端长时间无法收到服务器的回复,则认为网络已经断开。

六、Http协议的过程?

当输入www.baidu.com时,页面会作何选择:

1.域名解析

域名解析检查顺序为:浏览器自身DNS缓存---》OS自身的DNS缓存--》读取host文件--》本地域名服务器--》权限域名服务器--》根域名服务器;如果有且没有过期,则结束本次域名解析;域名解析成功之后,进行后续建立连接的操作。

2.tcp3次握手建立连接;

3.建立连接后,发起http请求;

4.服务器端响应http请求,浏览器得到到http请求的内容;

5.浏览器解析html代码,并请求html代码中的资源;

6.浏览器对页面进行渲染,将页面向用户展示。

七、说说你对RPC的了解?
RPC(Remote Promote Call)一种进程间通信方式;其允许像调用本地服务一样调用远程服务。
RPC框架的主要目标就是让远程服务调用更简单、透明;RPC框架负责屏蔽底层的传输方式(TCP或者UDP)、序列化方式(XML/JSON/二进制)和通信细节。
开发人员在使用的时候只需要了解谁在什么位置提供了什么样的远程服务接口即可,并不需要关心底层通信细节和调用过程。

八、怎么把http变为https?

JAVA环境下http修改https:使用.pfx证书
1.在Tomcat上部署PFX证书:打开Tomcat配置文件 conf\server.xml,注释code里有:Define a SSL HTTP/1.1 Connector on port 8443,取消注释并添keystoreFile,keystoreType,keystorePass属性:

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="C:/ProgramData/RSSBus/connect/data/test.pfx"
certificateKeystoreType="PKCS12"
certificateKeystorePassword="test" />
</SSLHostConfig>
</Connector>

2.重启Tomcat即可。

九、说说Mysql优化?

https://www.cnblogs.com/taojietaoge/p/11117806.html

 

Guess you like

Origin www.cnblogs.com/taojietaoge/p/11294430.html