1. Common scenario analysis for single-case mode.
In 23 design modes, the single-case model ranked eldest. Although the understanding is simple, but for the application scenario. Are you really familiar with that? The use of Singleton is because there is no need to create a new object for each request, which wastes both CPU and memory , and uses multiple cases to prevent concurrency problems, that is, one request changes the state of an object, and the object processes another request. The change in the state of the object before the request caused the object to handle the other request incorrectly.
Let's start with the singleton scenario in the Java Web: A database connection pool is a singleton pattern, and there is only one connection pool manager that manages multiple connection pool objects. Our common service and DAO layer objects are usually singleton (because all of their requests are handled with one object), and the action in Struts2 is multiple, because each request is handled with a new object (because the action itself contains the value of the request parameter, The state that can be changed). Log4j logging is also a singleton mode, because only one object is maintained from beginning to end. (Application of the log application, the general use of single-case mode implementation, which is generally due to the shared log file is always open, because there can only be one instance to operate, otherwise the content is not good to append).
2. What is a balanced binary tree.
It is either an empty tree, or a two-prong tree with the following properties: The absolute value of the difference in the depth of the Saozi right subtree is not more than 1, and its Saozi right subtree is a balanced binary tree.
3. What is a red-black tree?
The red-black tree is a special balanced binary tree. Follow the red theorem and the black theorem. Red theorem: Two contiguous red nodes cannot appear on one path; Black theorem: The root node must be a black node, and all nodes must have equal number of black nodes on the path to the end of the tree.
4. What is a B-tree? ( two-fork search tree )
All nodes store a keyword; the left pointer of a non-leaf node points to a subtree smaller than its key, and the right pointer points to a subtree greater than its keyword; all non-leaf nodes have up to two sons.
5. What is a B-tree. ( Multi-Path search tree )
root node son tree [2,m]; the son tree of non-root node non-leaf node [m/2,m]; the key word count for each node is [m/2-1,m-1].
6. What is a B + tree.
B-B Tree is a variant of S-tree, and on the definition of tree, the supplemental definition is: All the keywords appear on the leaf node, and all the leaf nodes add a chain pointer; the subtree of the non-leaf node is the same as the number of keywords.
Summary: The Balanced binary tree is a binary search tree. It is guaranteed to find nodes in the LOG2 (n) time, while the normal two-fork search tree has a worst-case performance approximation to the linked list with a time log (n). The red and black trees are sorted internally, that is, all in memory, and the internal implementation of the Microsoft STL map and set is the red-black tree. B-trees are mostly used in memory, and most of the data is stored on external memory. Because the B-tree has fewer layers, you can ensure that the disk is read as little as possible per operation. When the data is small and can be completely put into memory, the time complexity of the red-black tree is lower than the B-tree. Conversely, the large amount of data, when the main part of the external memory, B-tree because of its low number of read disk, and has a faster speed.
The origin of the red and black trees: in the search, although the hash table lookup is very fast, but with the increase in the variety of data, The length of the hash table will become longer, and the conflict will be more and more, then how to achieve whether in What is the size of the data, and is the search still high-performance? At the same time we know that the tree is a very good data structure, which is used to insert, delete, find and so are very efficient tree structure, but the problem is in a very bad situation, the operation is very time-consuming, its performance is not guaranteed, such as two binary search tree if the Zuozi and the right sub-tree too far , it can be time-consuming to find. At this time in order to ensure that it has high efficiency, it is necessary to ensure that the left tree and the right tree can not be too far away, when inserted into the tree, according to a certain rule adjustment, so that it reaches the rules, so that its overall and local search efficiency is improved. This is the rule of the red and black tree.
7. Final finally finalize the difference between the three.
Finalize is a method, and it is a method in the object class. The Finalize method that invokes the object when the garbage collector determines that the object is not referenced. Its role is to perform some necessary cleanup work for GC cleanup objects (such as the Finalize method of an input/output connected object to execute an explicit I/O transaction so that the connection is interrupted before the object is permanently discarded).
Finally used in the Try,catch anomaly mechanism, whatever the situation will be executed.
The final decorated class, which indicates that it cannot be inherited, modifies the base data type, that is, the constant is immutable, the reference type is modified, the object content is variable, and the object is immutable.
8. Error Exception RuntimeException
Inheritance structure of the exception mechanism first, the base class inherits exception such as Throwable;error and exception inheritance throwable;runtimeexception and IOException ( That is, the specific runtimeexception inherits RuntimeException).
Error describes an internal error and a situation where the resource is exhausted. Applications should not throw objects of this type (typically thrown by virtual machines). The program level cannot be processed.
The exception includes runtimeexception and other non-runtimeexception. RuntimeException includes wrong type conversions, array cross-border access, and attempts to access null pointers and so on. The principle of dealing with runtimeexception is that if a runtimeexception occurs, it must be a programmer's fault. For example, you can avoid array out-of-bounds access exceptions by examining array subscripts and arrays boundaries. Non-runtimeexception (IOException, etc.): Such exceptions are generally external errors, such as trying to read data from the end of a file, which is not an error in the program itself, but an external error that occurs in the application environment.
Summary: For example, 5/0 is runtimeexception exception, such an exception can not be processed in the program, no error, the runtime will report abnormal. Non-runtimeexception exception is in the program will be a try catch, not processing will be error .
9. Distinguish TCP UDP HTTP HTTPS SFTP FTP
TCP reliable connection, three handshake, four wave.
UDP is not a dependent connection.
HTTPS
Summary of the questions of Baidu Java research and development