Baidu written test java 3.28

 The following content is my memory after the written test, not necessarily correct, for reference only

Multiple choice questions, programming questions (same as 3.13)

1. The relationship between daemon thread, child thread and main thread

The difference between a daemon thread and a sub-thread is that the existence of a daemon thread will not prevent the end of the program. Even if the daemon thread is still running, the program can end, while the sub-thread must be executed before the program can end.

2. mysql optimistic lock, pessimistic lock

3. full gc trigger

  • When there is not enough space in the heap space to allocate new objects, a Full GC is triggered to reclaim useless objects and free up space.
  • When the number of objects in the old generation exceeds a certain threshold ( MaxTenuringThresholdspecified , the default value is 15), and the objects in the new generation cannot be promoted to the old generation, Full GC will be triggered to recycle the objects in the old generation and free up space.
  • When performing some specific garbage collection algorithms (such as CMS, G1, etc.), Full GC may also be triggered.

4. Three necessary conditions for the deadlock problem

  • Mutual exclusion: at least one resource is exclusively used by a process or thread, and other processes or threads cannot access the resource at the same time.
  • Request and hold conditions: A process or thread can request resources already occupied by other processes or threads, and keep the resources it has acquired without releasing them.
  • Circular wait condition: There exists a sequence of process or thread resource requests such that each process or thread is waiting for the next resource to be released, while the last process or thread is waiting for the first process or thread to release the resource.

5. linux systemctl command

(choose which command is not a subcommand of systemctl)

  • start <unit>: Start the specified service or unit.
  • stop <unit>: Stop the specified service or unit.
  • restart <unit>: Restart the specified service or unit.
  • reload <unit>: Reload the specified service or unit.
  • enable <unit>: Set the specified service or unit to start automatically when the system starts.
  • disable <unit>: Set the specified service or unit not to start automatically when the system starts.
  • status <unit>: Display the status information of the specified service or unit.
  • list-unit-files: List all available service unit files.
  • list-units: List all running service units.

6. mysql calculates average age based on gender

7. mysql SELECT 0; SELECT FALSE; SELECT NULL;

SELECT 0;: Returns the number 0.

SELECT FALSE;: Returns boolean false.

SELECT NULL;: Return NULL.

8. What is null in database

In databases, null represents a missing or undefined value and is equivalent to a null value. null is not equal to 0 or the empty string "", which represents no value, cannot be compared with any other value, and cannot be used for arithmetic operations. null can be used as a default value in a column, or to represent missing values ​​in query results.

9. Binary tree traversal method

(Pre-order traversal is XXX, in-order traversal is XXX, what is the nearest node to XX node)

10. Concurrent programming

11. There are n elements on the stack, how many ways are there to pop them out?

Cattelan Number Calculation Formula

7 corresponds to: 5040

6 corresponds to: 132

Guess you like

Origin blog.csdn.net/m0_56170277/article/details/129906074