2019 _BATJ manufacturers face questions Summary - SF articles

1.Hashmap bottom

The answer: https://blog.csdn.net/suifeng629/article/details/82179996

2.hashmap and hashtable difference?

The answer: https://blog.csdn.net/fxkcsdn/article/details/81487933

3.Hashmap Why is it unsafe thread-safe?

The answer: https://blog.csdn.net/weixin_43092168/article/details/89791106
https://blog.csdn.net/chisunhuang/article/details/79041656

4.MySQL index, engine, separate from the main reader

Master-slave configuration, separate read and write
in the actual production environment, a single Mysql as a standalone database is not fully meet the actual needs, both in terms of various security, high availability and high concurrency. Thus, in general it is to synchronize the data from the copy mode (Master-Slave) through the primary, then a scheme to enhance the load capacity of concurrent database by separate read and write (MySQL-Proxy) to deploy the embodiment.
Master-slave replication principle:
the main library (Master) to open binary log (binlog, record all log database operations); the main library authorize an account to the library (Slave), from the library as a client of the main library to access the main library binaries log to record their relay log (relay log) in; from the SQL thread library will detect its own relay logs, and perform;

The implementation process:
(1) the command execution start slave from the master copy switch is turned on, to start from the master copy on the server Slave.
(2) At this point, Slave server IO thread will request a connection Master server by copying the user rights on the master has authorized and requested the specified location from the implementation binlog log file (log file name and location is in the configuration master-slave replication services after the implementation of change master command specified) begin sending binlog log contents.
After (3) Master server receives a request from the IO Slave server thread, the thread which is responsible for replication of the IO read in batches binlog log information for the specified file specified binlog log information according to the location after the thread Slave IO requests to the server, and then back to the end of the Slave IO thread.
(4) When the server IO thread Slave to acquire the content log transmission of Master IO thread server, the log file and the location point, the contents will be sequentially written to the log binlog Slave terminal itself Relay Log (i.e. relay log) files ( Master server can tell Mysql-relay-bin.xxx) very end, and a new file name and location binlog recorded master-info file, so that the next end of the new master binlog read the specified file from the new log and log binlog binlog position to start reading the new contents of the log
(5) Slave server SQL thread real-time detection of a local Relay log in IO thread the new log, and then promptly put the contents of Relay lOG file parsed into sql statement, and in its own Slave order of position on the server parses SQL statements executed sql statement this application, and record the file name and location of the point of application of the current relay log in relay-log.info in

Separate read and write (read from master write)
from the server is only responsible for reading and writing the master server is responsible for the operation,
implementation:
judgment 1. Program (developers write their own)
2. Using middleware, MySQL- Proxy is to achieve "separate read and write (Read / Write Splitting) "of a software. The basic principle is to let the Lord handle database write operations (insert, update, delete), and from a database query processing operations (select). The consistency of the database is to achieve the main slave replication. So is the basis of the master copy from the separate read and write.
Detailed: https://blog.csdn.net/fsx2550553488/article/details/80575698

5.redis data types, use their own what?

Data Type:
1.String (string).
2.Hash (hash) key-value pair structure.
3.list (list), a list of ordered values may be repeated.
4.Set (set), unordered collection of values can not be repeated.
5.sort set (ordered set), an ordered collection of values can not be repeated.
redis usage scenarios:
session cache (Session Cache)
page caching (FPC)
Ranks / counter
Redis in memory for numbers increment or decrement operation to achieve very good.
redis advantages of
(1) fast, because the data stored in memory, similar to HashMap, HashMap advantage is to find the time and complexity of the operation is O (1)
(2) support for rich data types, support string, list, set, the sET sorted, hash
(3) support services, operations are atomic, so-called atomic changes to the data that is either all executed or not executed all
(4) rich feature set: can be used for caching, message, press the key to set expiration time expired will be automatically deleted

6. give you three threads abcb dependent on the results of a b c depend on the result of how you achieve?

The answer: https://www.cnblogs.com/scar1et/p/11900641.html

7. Shredded algorithm given in sorted array to find a first index value equal to the target, not -1

The answer: https://blog.csdn.net/weixin_42047723/article/details/93721826

8. subclass overrides the parent class throws an exception, the exception class can inherit a higher level than the parent?

See the sample code below:

import java.io.*;
 
public class Father {
	public void father_function() throws IOException {
		new File("a.txt");
	}
}
 
class Son extends Father {
	@Override
	public void father_function() throws Exception {
		new File("b.txt");
	}
}
 
class Test {
	public static void main(String[] args) {
		Father fs = new Son();
		try {
			fs.father_function();
		}catch (IOException ie) {
			System.out.println("发生了异常");
		}
	}
}

Code Description:

Defines a class, class named Father, Father contains a general example of a method, this method throws IOException
define a subclass of class Father: Son, parent class overrides the method of the Father, but subclasses after rewriting the method chosen to throw a bigger anomaly
defines a Test class contains a main method
Test class creates a class object son (ie Father subclass object class) and then use the try ... catch ... statement the fs.father_function (); this statement will throw an exception surrounded and use IOException objects on the current anomalies that may arise catch

Result: The program compilation failed

Cause Analysis:

1, in the java polymorphic mechanism, object reference fs at compile time type belonging to the parent class type i.e. Father, but belongs to the subclass fs runtime types, i.e. types Son

2, that is to say at compile time, the compiler found IOException catch in the parent class method can completely thrown exception is caught, so the compiler through, but at run time, because the fs into a sub-class type, subclass overridden method throws an exception is exception, IOException obviously can not capture the larger than it is abnormal, and therefore will fail at run time

Summary : When this example also demonstrates a truth, in java, parent class subclass overrides, if you select a subclass exception is thrown, the exception type thrown exception types can not be greater than the parent class

Published 53 original articles · won praise 88 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_43107323/article/details/104710793