Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the pitfalls in the java interview?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the pits in java interview". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

NO1. What should the output of this question be? Is it three fives?

Answer: The result is output 5,5,5. This question examines whether the interviewer understands how the class loading mechanism handles classes within the class. When the virtual machine loads static internal classes, if it is a certain attribute value, the virtual machine will directly store the value in the meta-store (static method area). Other uncertain values need to be dynamically calculated at runtime, and the virtual machine assigns addresses and values. If the value set is not static, it cannot be accessed directly, because the value belongs to the object and not the class.

No. 2. What is the output of this problem? Is it 100 or 99? I look forward to your participation and give you an answer in the next issue.

Answer: Looking at the results of everyone's reply, there are several small partners who answered correctly, and the output result is 0. Because the assignment operation has been completed before the self-increment operation. There are two storage areas in the JVM, one is the temporary storage area (hereinafter referred to as the stack), and the other is the variable area. j=j++ is to first store the value of j 0 in the stack, and then add 1 to j in the variable area. At this time, the value of j is indeed 1, but then the value in the stack is assigned to j in the variable area, so j=0 finally; and j=++j is to first add 1 to j in the variable area, then store the value of j (1) in the variable area into the stack, and finally assign the value in the stack to j in the argument area, so j=1;

NO3. Consider your problem with array and list conversion. What is the output of the following result?

Answer: The answer to this question is 1. Is your answer correct? This question examines the array of primitive types and reference types. When the array of primitive data types is converted to a list, if the array is passed directly, the array of primitive types will be regarded as an object and will not be resolved into an array. If the parameters are passed directly, it will be resolved normally. I hope everyone looks at the question carefully.

NO4. This question examines everyone's understanding of the set of equals. What is the output of the following program?

Answer: The answer to this question is true. Is it surprising? I also feel surprised, the two different types are the same, it is simply subversive of my view of knowledge, in fact, the two types have rewritten the equals method, compared the content and element length, there is no primary comparison of types. You see two types of equals methods and you understand why they are equal.

NO5.Can switch work on bytes, can switch work on long, can switch work on String?

Byte is supported, string is supported after JDK 1.7 (inclusive), but unfortunately long is not supported.

NO6. Name at least three ways to get the milliseconds from 0:00:00 on January 1, 1970 to the present?

This question is said to have stumped many farmers who have worked for more than 4 years! I'm scared. Frankly speaking, I only know the following one myself, although I have worked for many years... Interviewer: System.currentTimeMillis().

Interviewer: Friends and relatives group to fill in the answer, this is [preferred] interview a question, want to go to intelligent robot accurate.

Answer:

System.currentTimeMillis()。

new Date().getTime() 。

Calendar.getInstance().getTimeInMillis()。

Interviewer: Name three ways to get java class bytecode?

Interviewer: Class.class,object.getClass(), nothing else?! Interviewer: You can think about JDBC knowledge, maybe it will help you remember. Interviewer: No more...

Answer: There is actually another way to achieve this through reflection, as shown in the figure

NO8. There is also some understanding of JVM, can you simply say the difference between heap and stack?

Answer: Examining the interviewer's understanding of the two important storage units in the JVM, because space is limited, I will not describe them one by one, you can easily search for the answer. This is where the interviewer will ask where constants are stored, where objects are stored, where class attributes are stored, and so on. You can read this article:

https://blog.csdn.net/jasonwang18/article/details/70578647。

NO9. I think your back-end technology is OK. Do you understand the front-end? Can you tell me the difference between HTTP/1.1 and HTTP/1.0?

Answer: as shown in the picture

No. 10. Well, that's a good answer. What is the difference between POST and GET methods that everyone has heard but may not be able to explain?

Interviewer:

POST passes the request parameters hidden, while GET passes the parameters spliced to the request address;

POST is relatively secure while GET is vulnerable to tampering because of exposed parameters;

According to HTTP transmission protocol, both have different requirements for parameter length;

Interviewer: You can say more, basically.

Answer: In fact, the answer point is basically answered, in fact, the two are different when interacting with the server, POST method will request the server twice, the first time to send the header to confirm, the server returns successfully and sends the data again, and GET only needs to request the server once. At the same time, it is emphasized that the http protocol in the GET method does not impose parameter length restrictions, but different browsers and servers do limit it.

"What are the pits in java interview?" The content is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report