Facial Sutra - High Frequency Difficulty

1. What is the difference between a memory leak and a memory overflow?

Memory leak (memory leak): memory leak refers to the allocation of memory to temporary variables during the running of the program, but it is not reclaimed by GC after it is used up, and it always occupies memory, which can neither be used nor allocated to other programs, so memory occurs leakage.

Memory overflow (out of memory): To put it simply, memory overflow means that the memory requested during the running of the program is greater than the memory that the system can provide, resulting in the inability to apply for enough memory, so memory overflow occurs.

Avoid memory leaks: Release references to useless objects early. Avoid creating objects in loops. Avoid using String when working with string handling, use StringBuffer instead. Use static variables as little as possible, because static variables are stored in the permanent generation and basically do not participate in garbage collection.

Solution to avoid memory overflow: The first step is to modify the JVM startup parameters and directly increase the memory. The second step is to check the error log to see if there are other abnormalities or errors before the "OutOfMemory" error. The third step is to walk through and analyze the code to find out where memory overflow may occur. The fourth step is to use the memory viewing tool to dynamically view the memory usage.

3. Java memory area

During the execution of a Java program, the Java virtual machine divides the memory it manages into six runtime data areas.
Program counter, Java virtual machine stack, local method stack, method area, runtime constant pool

3. How the finalize() method works

Once the garbage collector is ready to release the storage space occupied by the object, it will first call its finalize() method, and the memory occupied by the object will not be actually recovered until the next garbage collection action occurs.

4. Class loading mechanism - parent delegation model

Parental delegation mode, that is, when the loader loads a class, it first delegates the request to its parent class loader for execution until the top-level startup class loader. If the parent class loader can complete the loading, it will return successfully, if not, the child class loader will try to load by itself.
Advantages: 1. Avoid repeated loading of classes 2. Avoid tampering with Java's core API

5. Generational recycling

Young Generation->Mark-Copy
Old Generation->Mark-Clear
Generational recycling is based on two facts: most objects will not be used soon, and some objects will not be useless immediately, but they will not last for a long time.

What is GC?

GC is the Java garbage collection mechanism. There are two conditions for GC triggering, one is when the program calls System.gc can be triggered, and the other is the system itself decides the timing of GC triggering.

What is Minor GC?

Reclaiming memory from the young generation space (including Eden and Survivor areas) is called Minor GC. When the Eden area is full, Minor GC is triggered.

What is Full GC?

Full GC is to clean up the entire heap space, including the young generation and the old generation.

Trigger conditions for Full GC

  • When calling System.gc, the system suggests to execute Full GC, but not necessarily
  • Insufficient space in the old generation
  • Insufficient space in method area
  • After Minor GC, the average size of the old generation is larger than the available memory of the old generation
  • When copying from Eden area and From Space area to To Space area, if the object size is larger than the available memory of To Space, the object is transferred to the old generation, and the available memory of the old generation is smaller than the object size

Double marking for garbage collection

The first mark: For an object that has no other references, check whether it is necessary to execute the finalize() method on the object. If it is not necessary, it means that it can be recycled directly. (Filter basis: whether the finalize method has been overridden or executed; because the finalize method can only be executed once).
The second mark: If the selected judgment bit needs to be executed, it will be put into the FQueue queue, and a low-priority finalize thread will be automatically created to perform the release operation. If an object is referenced by other objects before it is released, the object will be removed from the FQueue queue.

0

What is the difference between SSM and SpringBoot?
Tell me about the process of migrating the project SSM to SpringBoot? Is there any difficulty? Is the migration process just code migration, or are there additional business optimizations?
Why should the project be upgraded to SpringBoot?
The front end of your project uses JS, is Vue useful?
How is it deployed? Is there a dedicated classmate deployment?
How is Redis used in the project?
How to integrate Gateway and OAuth2.0 in the project?
Common annotations of SpringBoot
The difference between RestController and Controller
JVM:
the concept of memory leak and memory overflow
What are the garbage collection algorithms,
introduce them?
Introduce the old generation
Will the old generation be recycled?
MySQL:
MySQL injection?
How to optimize MySQL?

1

Basic data type
2. Static code block, when to execute it
3. Have you understood jvm?
No
4. Garbage collection mechanism
No
5. Java variable parameters

2

1. Talk about the understanding of Spring Boot
2. The understanding of dependency injection
3. The understanding of the caching mechanism; do you know the annotations of Redis?
4. HTTP three-way handshake and four-way handshake
These four questions are asked based on my project experience.

3

  1. Have you interacted with the backend?
    7. Has the database been used? Let me talk about the addition, deletion, modification and query of the database
  2. Have you ever touched Java?
  3. Have you used JSP?
  4. Have you ever used JQuery?

4

I didn't ask anything else during the whole process, only the project and two interviewers.

Self introduction

Deadbeat project

what is the project for

Specifically realized those functions

Does MySQL use transactions?

What framework is used to operate MySQL

The paging principle of MyBatis

Do you understand the principle of Nginx?

If something goes wrong in the project, how do you locate it?

Did you write the Vue part yourself? Can you build the Vue scaffolding yourself?

Has the ssm framework been integrated by itself?

How to Locate and Solve MySQL Slow Statements

Have you ever used Linux?

How much do you know about Linux

Know about Tomcat?

How the project is deployed

Whether the project deployment uses a jar package or a war package

5

  1. Self introduction
  2. Understand the message queue, talk about the principle of the message queue
  3. How to see mysql slow query
    4. How to solve slow query
    5. What is redis used for
    6. Talk about an internship
    7. Do you want to come to Jinan

6

Self-introduction
Tell me about the difference between your second project
String and StringBuffer?
Why is the MySQL index a B+ tree?
Talk about the implementation process of MVC?
Has reflection ever been used?
Have you ever understood SpringBoot?

7

Self-introduction
java object-oriented features
The role of encapsulation Does a
class support multiple inheritance?
Let’s talk about abstract classes.
The difference between abstract classes and interfaces.
Let’s talk about projects . Let’s
talk about IO streams. Why doesn’t Python
support multi-threading?
Common Linux
commands ? Do you understand the mechanism? Let’s talk about common tags in HTML



8

HR face: Ask about the intended location, internship time, family situation, job of the target, etc. It depends on whether you are willing to come to Inspur.
Two sides (video):

  1. Self introduction
  2. project
  3. How to implement multi-threading in the project
  4. The difference between Notify() and NotifyAll() (??? My last question talked about various thread management thread communication concurrency security issues, you just ask me this??? I don’t even want to face this question)
  5. Continue to chat about the project,
    the whole process is ten minutes, it is not one of the most watery interviews!
    Sanmian:
    Just OC...

1. Precautions and detailed discussions on the use of code blocks

insert image description here
insert image description here
insert image description here
insert image description here

2. Precautions and detailed discussion of final usage

  1. Final modified properties are also called constants, generally named after XX XX XX
  2. The final modified attribute must be assigned an initial value when it is defined, and it cannot be modified later. The assignment can be in one of the following
    positions
    [choose a position and assign the initial value]:
    ①Definition: such as public final double TAX_RATE=0.08; ②In the constructor ③In the code block.
  3. If the property modified by final is static, the initialization position can only be
    ① when it is defined; ② in the static code block, and cannot be assigned in the constructor.
  4. Final classes cannot be inherited, but objects can be instantiated.
  5. If the class is not a final class but contains a final method, the method cannot be overridden, but it can be inherited.
  6. Generally speaking, if a class is already a final class, there is no need to modify the method into a final method.
  7. final cannot modify the constructor (that is, the constructor)
  8. Final and static are often used together, which is more efficient and will not cause class loading. The underlying compiler has optimized it.
    class Demo{ public static final int i=16; //The following statement is output without final. static{ System.out.println("Java Education~");}

  9. Packaging classes (Integer, Double, Float, Boolean, etc. are all final), and String is also a final class.

3. Introduction to abstract classes

  1. When the abstract keyword is used to modify a class, the class is called an abstract class, and the access modifier abstract class name { }
  2. When the abstract keyword is used to modify a method, the method is an abstract method
    access modifier abstract return type method name (parameter list); //no method body, that is, without adding { }
  3. The value of the abstract class lies more in the design. After the designer designs, let the subclass inherit and implement the abstract class ()
  4. Abstract class is a knowledge point that examiners love to ask, and it is often used in frameworks and design patterns

4. Precautions and detailed discussions on the use of abstract classes

  1. Abstract classes cannot be instantiated, [example]
  2. An abstract class does not have to contain abstract methods. That is to say, there may be no abstract method in an abstract class, [example]
  3. Once a class contains an abstract method, the class must be declared as abstract [Description]
  4. abstract can only modify classes and methods, not attributes and others. [illustrate]
  5. Abstract classes can have any members [abstract classes are essentially classes], for example: abstract classes can have non-abstract methods, constructors, static properties, etc.
  6. An abstract method cannot have a body, that is, it cannot be implemented. As shown in the figure
    abstract void aaa ( ) { } ;//It is wrong, there cannot be a { } method.
  7. If a class inherits an abstract class, it must implement all the abstract methods of the abstract class, unless it itself declares itself as an abstract class.
  8. Abstract methods cannot be decorated with private, final, and static, because these keywords are contrary to rewriting.
    Abstract Class Best Practice - Template Design Pattern

5. Best practice of abstract class - template design pattern

  • Basic introduction
    The abstract class embodies the design of a template pattern. The abstract class is used as a general template for multiple subclasses. The subclasses are extended and transformed on the basis of the abstract class, but the subclasses generally retain the behavior of the abstract class.
  • Problems the template design pattern can solve
  1. When part of the internal implementation of the function is determined, part of the realization is uncertain. At this time, you can expose the uncertain part and let the subclass implement it.
  2. Writing an abstract parent class, the parent class provides a common method for multiple subclasses, and leaves one or more methods for its subclass implementation, which is a template pattern.

6. Internal classes

https://blog.csdn.net/m0_50736744/article/details/121476486?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22121476486%22%2C%22source%22%3A%22m0_50736744%22%7D

7. The frame system of collection

There are many collection classes in Java, which are mainly divided into two categories, as shown in the figure: [back down]

  • Interpretation
    1. The collection is mainly two groups (single-column collection, double-column collection)
    2. The Collection interface has two important sub-interfaces List Set, and their implementation subclasses are all single-column collections
    3. The implementation subclass of the Map interface is double-column Collection and storage of KV
    4. Remember the two pictures sorted out
    insert image description here
    insert image description here

8. Array

  1. The length must be specified initially, and once specified, cannot be changed
  2. The saved must be elements of the same type
  3. Schematic code for adding/deleting elements using an array - it is cumbersome
    to write a schematic code for expanding the Person array.
    Person[] pers = new Person[1];1//The size is 1
    per[0]=new Person();
    //Add a new Person object?
    Person[] pers2 = new Person[pers.length+1]; //Create a new array
    for(){}//Copy the elements of the pers array to pers2 pers2
    [pers2.length-1]=new Person();//Add a new object

9. Collection

  1. Any number of objects can be saved dynamically, which is more convenient to use!
  2. Provides a series of convenient methods for manipulating objects: add, remove, set, get, etc.
  3. Use the collection to add and delete the schematic code of new elements - concise

10、IO流

insert image description here
Buffered streams starting with Buffered are used to cache data when reading and writing data to reduce the number of IOs;

InputStreamReader and InputStreamWriter are conversion streams, which are used to convert byte streams into character streams;

The stream starting with Object is an object stream, which is used to realize the serialization of objects;

11. Introduce the life cycle of threads

insert image description here

In the life cycle of a thread, it goes through five states: New, Ready, Running, Blocked, and Dead. Especially when a thread is started, it cannot always "occupy" the CPU to run alone, so the CPU needs to switch between multiple threads, so the thread state will also switch between running and ready many times.

12. Talk about the communication method between Java multithreading

There are three main ways of thread communication in Java:

wait()、notify()、notifyAll()

If synchronized is used between threads to ensure thread safety, wait(), notify(), and notifyAll() can be used to realize thread communication. These three methods are not methods declared in the Thread class, but methods declared in the Object class. The reason is that each object has a lock, so let the current thread wait for the lock of an object, of course, it should be operated through this object. And because the current thread may wait for the locks of multiple threads, it is very complicated to operate through threads. In addition, these three methods are all local methods and are modified by final and cannot be overridden.

The wait() method allows the current thread to release the object lock and enter the blocked state. The notify() method is used to wake up a thread that is waiting for the corresponding object lock, so that it enters the ready queue, so that after the current thread releases the lock, it can compete for the lock, and then get the execution of the CPU. notifyAll() is used to wake up all threads that are waiting for the corresponding object lock, so that they enter the ready queue, so that they can compete for the lock after the current thread releases the lock, and then get the execution of the CPU.

Each lock object has two queues, one is the ready queue and the other is the blocking queue. The ready queue stores threads that are ready (to compete for locks), and the blocking queue stores blocked threads. When a blocked thread is woken up, it will enter the ready queue and wait for the CPU to schedule. Conversely, when a thread is waited, it will enter the blocking queue, waiting to be woken up.

Supongo que te gusta

Origin blog.csdn.net/m0_50736744/article/details/126489696
Recomendado
Clasificación