September, September, sweeping 20 Internet companies in Beijing! Summary of 21 interview questions necessary for JVM

JVM is a hurdle for the growth of Java programmers. Before learning JVM, you only need to know that the code is compiled into Class, and the virtual machine loads the Class to run. After learning JVM, you can deeply understand the process of code compilation to loading and objects in memory. The creation and garbage collection, the rapid positioning of performance problems in daily development, etc. are of course also indispensable bonus points for interviews.

I believe that during the interview, many people let JVM block the offer. Because of the lessons learned, I made sufficient preparations before going to the interview. I collected relevant interview information online, sorted it out, and screened out the interviews. The most frequently asked questions are shared here. I hope you can avoid those pits and get your favorite offer! (There is also an xmind mind map and a collation of core knowledge points )

1. Java class loading process?

Java class loading needs to go through 7 processes:

1. Load

2. Verification

3. Prepare

4. Analysis

5. Initialization

6. Use

7. Uninstall

 

2. Describe the principle and mechanism of JVM loading Class files?

The main steps of class loading:

1. Loading.

2. Link.

3. Check.

4. Prepare.

5. Analysis.

6. Initialization.

 

Three. Java memory allocation

1. Register

2. Static domain

3. Constant pool

4. Non-RAM storage

5. Heap memory

6. Stack memory

 

4. What is GC? Why do we have G

GC means garbage collection (GabageCollection). Memory processing is a place where programmers are prone to problems. Forgetting or wrong memory collection can cause instability or even crash of the program or system. The GC function provided by Java can automatically monitor whether the object exceeds the function. To achieve the purpose of automatically reclaiming memory, the Java language does not provide a display operation method to release allocated memory.

5. Briefly describe the Java garbage collection machine

In Java, the programmer does not need to explicitly release the memory of an object, but is executed by the virtual machine itself. In the JVM, there is a garbage collection thread, which is of low priority and will not be executed under normal circumstances. It will only be triggered when the virtual machine is idle or the current heap memory is insufficient. Reference objects and add them to the collection to be recycled for recycling.

6. How to judge whether an object is alive? (Or how to determine the GC object)

There are two ways to determine whether an object is alive:

1. Reference counting

 

2. Reachability algorithm (reference chain method)

 

7. The advantages and principles of garbage collection. And consider 2 types of recycling

8. What is the basic principle of the garbage collector? Can the garbage collector reclaim memory immediately? Is there any way to proactively notify the virtual machine for garbage collection

9. Will there be a memory leak in Java? Please describe briefly

10. Deep copy and shallow copy

11. What will System.gc() and Runtime.gc() do?

12. When is the finalize() method called? What is the purpose of finalization?

13. If the object reference is set to null, will the garbage collector immediately release the memory occupied by the object?

14. What is distributed garbage collection (DGC)? How does it work?

15. What is the difference between a serial collector and a throughput collector?

16. In Java, when can an object be garbage collected?

17. Briefly describe the Java memory allocation and recovery strategy, Minor GC and Major GC.

18. Will garbage collection occur in the permanent generation of the JVM?

19. What are the methods of garbage collection in Java?

Twenty. What is a class loader, and what are the class loader?

21. The parent delegation model mechanism of the class loader?

 

 

 

 

Because of the length of the article, I will not show the answers one by one. Friends who are interested in JVM interview questions or want to learn more about JVM, I will share these documents here. Friends who need it, add assistant VX: mxx2020666, free receive

Guess you like

Origin blog.csdn.net/m0_46995061/article/details/109333193