Objective
Today, in the Nuggets, I saw an article about the spring framework of the explanation, and the article mentioned the question of the cow-guest net. So I downloaded the Ox-Guest web app and found the interview topic is very rich. I chose the Java side of the face of the question to do a bit. 10 topics for a group of interview questions, after the completion, I found myself wrong a lot, most of them are basic problems. As the saying goes: The depth of the foundation determines the height of the future. I feel I have to do a wrong to sum up and summarize, the previous study of the omission of knowledge in the Java process to review again, just to take this opportunity. At the same time, I also feel that theoretical knowledge is also very important, theory around the idea, supporting the quality of the code.
Wrong problem induction
Question 3rd
Write a picture description here
It's easy to make a mistake without looking at the subject, which is certainly 4. In fact, the correct answer is 10, because the lack of break;
Induction:
- When there is no break in the switch structure, matching to the appropriate value will not jump out. It will always match to the last case until the end of the entire structure.
Question 4th
Write a picture description here
Induction:
- The first string calls the substring () method to obtain a substring from the current string, which is a string that is truncated from the start of the current string to the end, but does not contain the corresponding character of the end.
- Garbage collection is primarily about the recycling of heap memory, because the memory of the stack is released as the thread. The heap area is divided into 3 districts: The young generation, the old generation, and the permanent generation (method area).
- Young generation: objects created by the new operator are usually assigned to young generations. A certain Minor GC (Minor GC is a garbage collector for younger generations of memory) also survives objects that are moved to older generations.
- older generation: It is the young generation that moved over and some of the larger objects. The full GC is for the old generation garbage collector.
- permanent Generation: stores the final modified constants, static variables, and constant pools.
Answer:
First STR0,STR1 is a static constant, stored in the heap memory for a permanent generation. STR2 is also a new object, because substring is actually a new string object in the source code, and returns, STR3 and STR4 are created directly from the newly operator. STR2,STR3,STR4 is a young generation that is stored in the heap area. After the full GC, the old generation of memory is cleaned up and recycled. No permanent generation, only the younger generation. So the younger generation 5*3=15 the number of characters
Tail words
Adhere to the basic knowledge of the omission of the day to know the new.
Welcome to join the Learning Exchange Group 569772982, we learn to communicate together.
Summary and generalization of the problem of the Java plane question in the cattle net (1)