Niuke.com Wrong Question Collection 11

1.

Analysis of knowledge points:

 A. Files are divided into text files and binary files. Computers only know binary, so they are actually different interpretations of binary. Text files are characters displayed in different encoding formats, such as Ascii, Unicode, etc. The suffixes of text files in windows are ".txt", ".log", source files of various programming languages, etc.; binary files are text files. You can't read garbled characters when you open them. As long as you can open a file with text, it can be regarded as a text file, but the displayed result is not what you want. Binary files can only be read by special applications, such as ".png"," .bmp", etc., most of the files in the computer are still binary files. 

B. The File class is a class that operates on the entire file or file attributes, such as creating a file, deleting a file, and checking whether the file exists. It cannot operate the file content; the file content is operated by IO streams. 

C. When the end of the file or stream is unexpectedly reached during the input process, an EOFException is thrown. Normally, when the end of the file is read, a special value is returned to indicate that the file reading is completed. For example, read() returns -1 to indicate that the file is read. Take complete. 

D. The above option A has already said that whether it is a text file or a binary file, it is stored in binary form in the computer, so it is read as a binary file. 

2.
 Statement Every time the SQL statement is executed, the database must execute the compilation of the SQL statement. It is best used in the case where only one query is executed and the result is returned, and the efficiency is higher than that of PreparedStatement. 

PreparedStatement is precompiled, and using PreparedStatement has several advantages 

 : a. When executing a SQL with variable parameters, PreparedStatement is more efficient than Statement, because DBMS precompiling a SQL is of course more efficient than compiling a SQL multiple times. 

 b. Good security, effectively preventing Sql injection and other problems. 

 c. For statements that are executed repeatedly, it is more efficient to use PreparedStament, and batch is also more suitable in this case; 

 d. The readability and maintainability of the code. 

  

The CallableStatement interface extends PreparedStatement for calling stored procedures, which provides support for output and input/output parameters. The CallableStatement interface also has support for input parameters provided by the PreparedStatement interface. 

 Summarize:
 api: 

public interface CallableStatement extends PreparedStatement 

public interface PreparedStatement extends Statement 

3.
                

Method 1: free 

intuitively displays the memory usage of the Linux system and the capacity of the swap area, etc. 

               

Method 2: top 

dynamically checks the resource usage of each process in the system in real time 

               

Method 3: cat /proc/meminfo 

               

Method 4: gnome-system-monitor A view tool that shows CPU, memory, swap and network usage over a recent period of time. 

               

Method 5: ps aux –sort -rss 

Resource usage of each thread 

               

Method 6: vmstat -s 

The vmstat command displays real-time and average statistics, covering CPU, memory, I/O, etc. 

4.
          Linux provides a mechanism to ensure that as long as the parent process wants to know the status information at the end of the child process, it can get it. This mechanism is: when each process exits, the kernel releases all the resources of the process, including open files, occupied memory, etc. However, certain information is still reserved for it (including the process ID, the exit status, the termination status of the process, the amount of CPU time taken by the process, etc.). It is not released until the parent process takes it through wait/waitpid. 


        Orphaned process: A parent process exits while one or more of its child processes are still running, then those child processes will become orphaned. The orphan process will be adopted by the init process (process number is 1), and the init process will complete the state collection work for them. 

        Zombie process: A process uses fork to create a child process. If the child process exits and the parent process does not call wait or waitpid to obtain the status information of the child process, the process descriptor of the child process is still stored in the system. Such a process is called a zombie process. 


         The zombie process is not the root cause of the problem. The culprit is the parent process that produces a large number of zombie processes. Therefore, the solution is to kill the parent process, so that the zombie process can be received and released by the init process. 

5.

The uptime command used to only show how long the system was up. Now, how long the system has been running can be displayed, the information displayed in order is: the current time, how long the system has been running, how many users are currently logged in, the average load of the system in the past 1 minute, 5 minutes and 15 minutes . 

The top command can view 

the explanation of the last output information of the overall status of the system: 

load average: 0.09, 0.05, 0.01 

The three numbers represent the average load of the system in different time periods (one minute, five minutes, and fifteen minutes), and their numbers The smaller the better. In multi-core processing, the average value of the system should not be higher than the total number of processor cores. 

The memory used by the process can be used top, there are 3 columns VIRT RES SHR, indicating the memory used by the process, VIRT identifies the memory that the process can use The total size, including the memory actually used by this process, the mapped files, and the memory shared with other processes, etc. RES identifies the actual memory size occupied by this process. SHR identifies the memory and library size that can be shared with other processes. 

The sar -u output shows CPU information. The -u option is the default option for sar. The output shows the CPU usage in percentage. 

ls is the same as the dir command under dos. It is used to list the files in the directory. 

crontab is a scheduled task command and cannot view the system load. 


6.

Use generics to replace non-generic data types (such as ArrayList<String> instead of ArrayList) in development, and the runtime performance of the program will become better. 

This sentence is wrong.

Generics do not affect the code formed by the Java virtual machine. During the compilation phase, the virtual machine will erase the generic type and restore it to code without generics.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325726661&siteId=291194637