Summary of 2021 high-frequency common 200+Java interview questions (with answer analysis)

Preface

The Golden Three and the Silver Four have come, and many friends are asking if they have sorted out some of the interview questions from last year. Recently, I took the time to sort out a Java interview question. Perhaps this interview question is not enough to cover all Java questions, but with it, I believe it is sufficient to deal with most of the current Java interviews on the market, because this article has already covered both in depth and breadth. A lot of knowledge points.

The modules included in this interview question are divided into 19 modules, namely: Java Basics, Containers, Multithreading, Reflection, Object Copy, Java Web, Exceptions, Network, Design Patterns, Spring/Spring MVC, Spring Boot/Spring Cloud , Hibernate, MyBatis, RabbitMQ, Kafka, Zookeeper, MySQL, Redis, JVM. As shown below

This article is mainly to organize a more practical interview list for readers and friends, let's enter the topic together.

Summary of interview questions

One, Java basic series of interview questions

1. What is the difference between JDK and JRE?

2. What is the difference between == and equals

3. If the hashCode() of two objects is the same, equals() must be true, right?

4. What is the role of final in Java?

5. What is the equivalent of Math. round(-1. 5) in Java?

6. Is String a basic data type?

7. What are the classes for manipulating strings in Java? What is the difference between them?

8. Is String str="i" the same as String str=new String("i")?

9. How to reverse the string?

10. What are the commonly used methods of the String class?

11. Does an abstract class have to have abstract methods?

12. What is the difference between a normal class and an abstract class?

13. Can abstract classes use final modification?

14. What is the difference between an interface and an abstract class?

15. How many types of IO streams are in Java?

16. What is the difference between BIO, NIO and AIO?

17. What are the common methods of Files?

Second, the container series of interview questions

18. What are the Java containers?

19. What is the difference between Collection and Collections?

20. What is the difference between List, Set and Map?

21. What is the difference between HashMap and Hashtable?

22. How to decide whether to use HashMap or TreeMap?

23. Tell me about the implementation principle of HashMap?

24. Tell me about the implementation principle of HashSet?

25. What is the difference between ArrayList and LinkedList?

26. How to realize the conversion between array and List?

27. What is the difference between ArrayList and Vector?

28. What is the difference between Array and ArrayList?

29. What is the difference between poll() and remove() in Queue?

30. Which collection classes are thread safe?

31. What is Iterator?

32. How to use Iterator? What are the characteristics?

33. What is the difference between Iterator and ListIterator?

34. How to ensure that a collection cannot be modified?

Three, multi-threaded series of interview questions

35. What is the difference between parallel and concurrency?

36. The difference between thread and process?

37. What is a daemon thread?

38. What are the ways to create threads?

39. Tell me about the difference between runnable and callable?

40. What are the statuses of threads?

41. What is the difference between sleep() and wait()?

42. What is the difference between notify() and notifyAll()?

43. What is the difference between thread run() and start()?

44. What are the ways to create a thread pool?

45. What are the statuses of the thread pool?

46. ​​What is the difference between the submit() and execute() methods in the thread pool?

47. How to ensure the safe operation of multiple threads in a Java program?

48. What is the principle of synchronized lock upgrade in multithreading?

49. What is a deadlock?

50. How to prevent deadlock?

51. What is ThreadLocal? What are the usage scenarios?

52. Tell me about the underlying implementation principle of synchronized?

53. What is the difference between synchronized and volatile?

54. What is the difference between synchronized and Lock?

55. What is the difference between synchronized and ReentrantLock?

56. Tell me about the principle of atomic?

Four, reflection, object copy, Java Web interview questions

57. What is reflection?

58. What is Java serialization? Under what circumstances need serialization?

59. What is a dynamic agent? What are the applications?

60. How to implement dynamic proxy?

61. Why use cloning?

62. How to implement object cloning?

63. What is the difference between deep copy and shallow copy?

64. What is the difference between JSP and servlet?

65. What built-in objects does JSP have? What are the roles?

66. Tell me about the 4 scopes of JSP?

67. What is the difference between session and cookie?

68. Tell me about the working principle of session?

69. Can the session be used if the client prohibits cookies?

70. What is the difference between spring mvc and struts?

71. How to avoid SQL injection?

72. What is XSS attack and how to avoid it?

73. What is a CSRF attack and how to avoid it?

Five, anomaly, network, design pattern series of interview questions

74. The difference between throw and throws?

75. What is the difference between final, finally, and finalize?

76. Which part of try-catch-finally can be omitted?

77. In try-catch-finally, if the catch is returned, will finally be executed?

78. What are the common exception classes?

79. What do the http response codes 301 and 302 represent? What's the difference?

80. The difference between forward and redirect?

81. Briefly describe the difference between tcp and udp?

82. Why does tcp need to shake hands three times? why?

83. Tell me about how tcp sticky packets are generated?

84. What are the seven-layer models of OSI?

85. What is the difference between get and post requests?

86. How to achieve cross-domain?

87. Tell me about the principle of JSONP implementation?

88. Tell me about the design patterns you are familiar with?

89. What is the difference between a simple factory and an abstract factory?

Six, Spring, Spring MVC, Spring Boot, Spring Cloud series of interview questions

90. Why use spring?

91. Explain what is aop?

92. Explain what is ioc?

93. What are the main modules of spring?

94. What are the commonly used injection methods for spring?

95. Are beans in spring thread-safe?

96. What scope of beans does spring support?

97. What are the ways to automatically assemble beans in spring?

98. What are the implementation methods of spring transaction?

99. Tell me about Spring's transaction isolation?

100. Tell me about the running process of spring mvc?

101. What are the components of spring mvc?

102. What is the role of @RequestMapping?

103. What is the role of @Autowired?

104. What is spring boot?

105. Why use spring boot?

106. What is the core configuration file of spring boot?

107. What types of spring boot configuration files are there? What is the difference between them?

108. What are the ways to achieve hot deployment of spring boot?

109. What is the difference between jpa and hibernate?

110. What is spring cloud?

111. What is the function of the spring cloud circuit breaker?

112. What are the core components of spring cloud?

Seven, Hibernate, MyBatis series of interview questions

113. Why use hibernate?

114. What is the ORM framework?

115. How to view the printed SQL statement in the console in hibernate?

116. How many query methods does hibernate have?

117. Can hibernate entity classes be defined as final?

118. What is the difference between using Integer and int for mapping in hibernate?

119. How does hibernate work?

120. The difference between get() and load()?

121. Tell me about hibernate's caching mechanism?

122. What are the statuses of hibernate objects?

123. What is the difference between getCurrentSession and openSession in hibernate?

124. Does the hibernate entity class have to have a parameterless constructor? why?

125. What is the difference between #{} and in MyBatis?

126. How many paging methods does MyBatis have?

127. Is RowBounds querying all results at once? why?

128. What is the difference between logical paging and physical paging in MyBatis?

129. Does MyBatis support lazy loading? What is the principle of lazy loading?

130. Tell me about the primary cache and secondary cache of MyBatis?

131. What are the differences between MyBatis and hibernate?

132. What executors (Executor) does MyBatis have?

133. What is the realization principle of the MyBatis paging plug-in?

134. How to write a custom plug-in for MyBatis?

Eight, RabbitMQ, Kafka, Zookeeper series interview questions

135. What are the usage scenarios of RabbitMQ?

136. What are the important roles of RabbitMQ?

137. What are the important components of RabbitMQ?

138. What is the role of vhost in RabbitMQ?

139. How are RabbitMQ's messages sent?

140. How does RabbitMQ ensure the stability of messages?

141. How does RabbitMQ avoid message loss?

142. What are the conditions to ensure the success of message persistence?

143. What are the disadvantages of RabbitMQ persistence?

144. How many broadcast types does RabbitMQ have?

145. How does RabbitMQ implement a delayed message queue?

146. What is the use of RabbitMQ cluster?

147. What are the types of RabbitMQ nodes?

148. What issues should be paid attention to when setting up RabbitMQ cluster?

149. Is each node of RabbitMQ a complete copy of other nodes? why?

150. What happens if the only disk node in the RabbitMQ cluster crashes?

151. Does RabbitMQ have any requirements for the stopping order of cluster nodes?

152. Can Kafka be used separately from zookeeper? why?

153. How many data retention strategies does Kafka have?

154. Kafka has set 7 days and 10G to clear data at the same time. By the fifth day, the message reached 10G. What will Kafka do at this time?

155. What circumstances will cause Kafka to run slower?

156. What should I pay attention to when using kafka cluster?

157. What is zookeeper?

158. What are the functions of zookeeper?

159. How many deployment modes does zookeeper have?

160. How does zookeeper ensure that the status of the master and slave nodes are synchronized?

161. Why is there a master node in the cluster?

162. There are 3 servers in the cluster, and one of the nodes is down. Can zookeeper still be used at this time?

163. Tell me about the notification mechanism of zookeeper?

Nine, MySQL series of interview questions

164. What are the three paradigms of the database?

165. There are 7 pieces of data in an auto-increment table. The last 2 pieces of data are deleted, the MySQL database is restarted, and another piece of data is inserted. What is the id at this time?

166. How to get the current database version?

167. What is ACID?

168. What is the difference between char and varchar?

169. What is the difference between float and double?

170. What is the difference between inner connection, left connection and right connection of MySQL?

171. How is the MySQL index implemented?

172. How to verify whether the MySQL index meets the demand?

173. Talk about the transaction isolation of the database?

174. Tell me about the commonly used engines of MySQL?

175. Tell me about row locks and table locks in MySQL?

176. Talk about optimistic locking and pessimistic locking?

177. What are the methods for MySQL troubleshooting?

178. How to optimize the performance of MySQL?

Ten, Redis series of interview questions

179. What is Redis? What are the usage scenarios?

180. What are the functions of Redis?

181. What is the difference between Redis and memcache?

182. Why is Redis single-threaded?

183. What is cache penetration? How to deal with it?

184. What are the data types supported by Redis?

185. What are the Java clients supported by Redis?

186. What is the difference between jedis and Redisson?

187. How to ensure the consistency of cache and database data?

188. There are several ways to persist Redis?

189. How does Redis implement distributed locks?

190. What are the defects of Redis distributed lock?

191. How Redis does memory optimization

192. What are the Redis elimination strategies?

193. What are the common performance problems of Redis? How to solve it?

Eleven, JVM series of interview questions

194. Tell me about the main components of JVM? And its role?

195. Tell me about the JVM runtime data area?

195. Tell me about the JVM runtime data area?

196. Tell me about the difference between stacks?

197. What are queues and stacks? What's the difference?

198. What is the parental delegation model?

199. Tell me about the execution process of class loading?

200. How to judge whether the object can be recycled?

201. What reference types are there in Java?

202. Tell me about what garbage collection algorithms the JVM has?

203. Tell me about what garbage collectors the JVM has?

204. Tell me more about the CMS garbage collector?

205. What are the new generation garbage collectors and the old generation garbage collectors? What's the difference?

206. Briefly describe how the generational garbage collector works?

207. Tell me about JVM tuning tools?

208. What are the commonly used JVM tuning parameters?

to sum up:

All the interview questions are not static. The above interview questions are just a reference for everyone. The most important thing is to increase your knowledge reserve and be prepared. The answers to the 2021 latest 200+Java interview questions shared above are all organized into PDF documents.

Click on the portal if you need to receive it

Guess you like

Origin blog.csdn.net/Java6888/article/details/115017067