2021 Java Spring Recruitment Advanced Interview Guide (Required for Java Interviewers for 1 to 5 Years)

The golden three and the silver four are still going on, and it is another good season for job-hopping. The students who are ready to switch jobs are gearing up to prepare for several games. Today, we have prepared the interviews that must be mastered by Java interviewers for 1 to 5 years, which are necessary for Internet interviews. Questions, respectively JVM, concurrent programming, MySQL, Tomcat, network and IO and Spring series, etc., it can be said that it is possible to master these salary increases by 10K!

What I shared with you today is the most frequently used interview question bank by mainstream companies, and they are all the latest answers after the Java version upgrade, which will save the interviewees a lot of unnecessary detours. At the same time, detailed interview analysis documents have been made for each topic to ensure that readers at each stage can understand it.

Each knowledge point has a left-side navigation bookmark page, which is very convenient to read. Due to the large amount of content, here is a screenshot of some pictures. Readers and friends who need it can help forward and support, just click to send ! !

 

One, Java basics

  1. What is the main class of a Java program? What is the difference between the main class of an application and an applet?
  2. Can Constructor be overridden?
  3. What is the difference between String StringBuffer and StringBuilder? Why is String immutable?
  4. What is the difference between the equality of objects and the equality of references to them?
  5. What is the difference between overloading and rewriting?
  6. Why is it illegal to call a non-static member in a static method?
  7. Briefly describe the basic concepts of threads, programs, and processes. And what is the relationship between them
  8. What is the return value of a method? What is the function of the return value in the method of the class?
  9. What is the role of a class's constructor? If a class does not declare a constructor, can the program be executed correctly? Why?
  10. Three characteristics of Java object-oriented programming: encapsulation inheritance polymorphism
  11. What if some fields do not want to be serialized in Java serialization?
  12. Before calling the subclass construction method, the parent class construction method without parameters will be called first. What is the purpose?
  13. What are the basic states of threads?
  14. What operator is used to create an object? What is the difference between an object entity and an object reference?
  15. What are the differences between member variables and local variables?

 

Two, Java Intermediate

  1. What are Spring's AOP and IOC? What are the usage scenarios? Spring transaction, transaction attributes, database isolation level
  2. What are the annotations of Spring and SpringMVC, MyBatis and SpringBoot?
  3. What are the SpringCould components and what are their functions? What is the CAP of microservices? What is BASE?
  4. HashMap bottom layer realization principle, red-black tree, B+ tree, B tree structure principle, CAS (comparison and exchange) realization principle
  5. Data types and usage scenarios supported by Redis, persistence, sentinel mechanism, cache breakdown, cache penetration
  6. What is a thread, there are several ways to implement it, what is the difference between them, the principle of thread pool implementation, and the JUC concurrent package
  7. Security issues (data tampering (getting someone else’s URL, tampering with the data (amount) sent to the system))
  8. Restrictions on the use of indexes, what are the sql optimizations, and data synchronization issues (caching, database data synchronization)
  9. Distributed transaction
  10. Heap overflow, stack overflow scenarios and solutions
  11. What are pessimistic locks, optimistic locks, read-write locks, row locks, table locks, spin locks, deadlocks, distributed locks, thread synchronization locks, fair locks, and unfair locks?
  12. There are several steps to initialize a Bean object, its life cycle
  13. JVM memory model, algorithm, garbage collector, tuning, class loading mechanism (parent delegation), create an object, how is this object allocated in memory?
  14. The operating principle of Dubbo, why is it more efficient than SpringCould, and the underlying principle of Zookeeper
  15. Tell the difference between several kinds of MQ, and why this MQ is used, the message is sent repeatedly (idempotence), the message sending fails, the message packet is dropped, the message is not received for a long time, and the message sent is too large, resulting in unsuccessful reception

 

Three, Java advanced

  1. Why use message queues? What are the advantages and disadvantages of message queues? What are the advantages and disadvantages of Kafka, ActiveMQ, RabbitMQ, RocketMQ?
  2. How to ensure that messages are not re-consumed? In other words, how to ensure the idempotence of message consumption?
  3. How to solve the delay and expiration of the message queue? What should I do when the message queue is full? There are millions of news backlogged for a few hours, talk about how to solve it?
  4. Can you talk about the working principle of redis cluster mode? In cluster mode, how are redis keys addressed? What are the algorithms for distributed addressing? Do you know the consistent hash algorithm?
  5. Understand what is the avalanche, penetration and breakdown of redis? What happens after redis crashes? How should the system respond to this situation? How to deal with redis penetration?
  6. Why sub-database and table (how to design the database level when designing a high-concurrency system)? Which sub-database and sub-table middleware have been used? What are the advantages and disadvantages of different database and table middleware? How do you specifically split the database vertically or horizontally?
  7. Is MySQL separation of reads and writes done? How to realize the separation of reading and writing in MySQL? What is the principle of MySQL master-slave replication? How to solve the delay problem of MySQL master-slave synchronization?
  8. Tell me about the working principle of dubbo? Can the communication be continued after the registration center is hung up? Tell me about the process of an rpc request?
  9. How to perform service governance, service degradation, failure retry and timeout retry based on dubbo?
  10. How to implement distributed session in cluster deployment?
  11. What does service registration and discovery mean? How to implement Spring Cloud?
  12. What are the general ways to implement distributed locks? How to design points using redis
  13. Cloth lock? Is it okay to use zk to design distributed locks? Which of the two implementations of distributed locks is more efficient?
  14. What is dubbo's spi idea?
  15. How to design a sub-database and sub-table solution that can dynamically expand and shrink?

 

Four, distributed

  1. Is the message retransmission interval and retransmission times in ActiveMQ?
  2. How Kafka creates Topic and places partitions in different Brokers
  3. What are the two conditions for Kafka to judge whether a node is still alive?
  4. Does Kafka message use Pull mode or Push mode?
  5. Compared with the server's local cache (such as PHP APC, mmap file, etc.), what are the advantages and disadvantages of memcached?
  6. I need to export and import items in memcached in batches, what should I do?
  7. What is the multithreading of memcached? How to use them?
  8. MongoDB builds an index on A:{B,C}. Will queries A:{B,C} and A:{C,B} use the index?
  9. Does MongoDB support stored procedures? If it is supported, how to use it?
  10. How to understand the GridFS mechanism in MongoDB, why does MongoDB use GridFS to store files?
  11. In Nginx, how to use an undefined server name to prevent requests from being processed?
  12. Is there a limit on the number of messages stored in a queue on RabbitMQ?
  13. If the owner node that owns a certain queue in the cluster fails and the queue is declared to have the durable attribute, can the queue be successfully re-declared from other nodes?
  14. Why do we say that the condition to ensure that the message is reliably persisted is that queue and exchange have durable attributes, while message has persistent attributes?
  15. Why use cache, which caches have been used, the difference between redis and memcache?

 

Five, Spring architecture

  1. What is the difference between Spring Boot, Spring MVC and Spring?
  2. What is the difference between BeanFactory and ApplicationContext?
  3. What is the Spring annotation configuration based on Java? Give some annotation examples.
  4. Please explain the life cycle of Spring Bean?
  5. Are singleton beans in the Spring framework thread-safe?
  6. Is the controller of SpringMvc a singleton mode? If so, what are the problems and how to solve them?
  7. How to set redirection and forwarding in SpringMVC?
  8. When a method returns a special object to AJAX, such as Object, List, etc., what needs to be done?
  9. What object does SpringMvc use to transfer data from the background to the foreground?
  10. What does service registration and discovery mean? How to implement Spring Cloud?
  11. What are the advantages of using Spring Cloud?
  12. What is a Hystrix circuit breaker? Do we need it?
  13. What is Spring Cloud Bus? Do we need it?
  14. How to realize the security of Spring Boot application?
  15. What is the name of the default H2 database configured by Spring Boot? Why is the default database name testdb?

 

Six, thread problems

  1. Why are the stop() and suspend() methods deprecated?
  2. What are the similarities and differences between synchronous and asynchronous, and when should they be used?
  3. Inter-thread communication, wait and notify
  4. What is a thread starving to death, and what is a livelock?
  5. Understanding and use of keywords for thread-safe operations such as atomicinteger and volatile
  6. What is a volatile variable? What is the difference between volatile variables and atomic variables?
  7. When a thread enters a synchronized method of an object, can other threads enter other methods of this object?
  8. Briefly describe the similarities and differences between synchronized and java.util.concurrent.locks.Lock?
  9. In the synchronization problem of communication between multiple threads, synchronized locks are objects, and there are many specific issues related to synchronization. For example, different methods of the same class have synchronized locks, and whether an object can be accessed at the same time. Or the static construction method of a class plus the influence of the lock after synchronized.
  10. What guarantee does volatile type variables provide? Can a non-atomic operation become an atomic operation?
  11. Understand the meaning of reentrant locks and the difference between ReentrantLock and synchronized
  12. After Java creates a thread, the difference between calling the start() method and run() directly
  13. Synchronous data structure, such as the source code understanding of concurrentHashMap and internal implementation principles, why it is synchronous and efficient
  14. Common thread pool modes and usage scenarios of different thread pools
  15. What will happen to newFixedThreadPool if the number of threads in this thread pool reaches the maximum? The underlying principle.

 

Seven, the network

  1. Why do you need three handshake
  2. What's wrong with the second handshake
  3. What are the defects of the three-way handshake
  4. How TCP controls traffic
  5. The sender's sending frequency is too high, causing packet loss, how does TCP solve it?
  6. Why should HTTPs use symmetric encryption + asymmetric encryption, and what are the advantages over only using asymmetric encryption?
  7. Talk about the OSI network architecture
  8. Which layer is HTTP at?
  9. HTTP message structure
  10. HTTP header field
  11. Which layer of HTTPs encryption is implemented?
  12. http is stateless communication. What are the HTTP request methods? Can you define new request methods yourself?
  13. Socket communication, and handling of long connections, sub-packaging, and abnormal disconnection of connections.
  14. The use of socket communication model, AIO and NIO.
  15. The use of socket framework netty, and the realization principle of NIO, why is it asynchronous and non-blocking

 

Eight, MySQL database

  1. Four major characteristics (ACID) atomicity, consistency, isolation, and durability?
  2. The different elements of the query statement (where, jion, limit, group by, having, etc.) are executed in order?
  3. What is the difference between the three common MySQL storage engines (InnoDB, MyISAM, MEMORY)?
  4. MySQL's MyISAM and InnoDB storage engines, transaction and lock levels, and their respective applicable scenarios?
  5. mysql high concurrency environment solution?
  6. Concurrency of transactions? Transaction isolation level, what problems will each level cause, which level is MySQL by default?
  7. What is the difference between MySQL B+Tree index and Hash index?
  8. What are the locks (optimistic locks, pessimistic locks), and how to add exclusive locks when selecting?
  9. sql query statement to determine which type of index to create? How to optimize the query?
  10. What is the difference between a clustered index and a non-clustered index?
  11. What kind of locks does mysql have, the principle of deadlock determination and specific scenarios, and how to solve the deadlock?
  12. What are the differences between non-relational databases and relational databases, and what are the advantages?
  13. How to solve MySQL slow query?
  14. 7 problems of database read-write separation, master-slave replication, master-slave replication analysis?
  15. Transaction recovery mechanism (REDO log and UNDO log) when the database crashes?

 

Nine, Redis cache

  1. What are the redis transaction related commands?
  2. Why use redis / why use cache (high performance, high concurrency)
  3. Why use redis instead of map/guava for caching?
  4. The difference between redis and memcached
  5. Please introduce the Redis data type SortedSet (zset) and the underlying implementation mechanism?
  6. Redis common data structure and usage scenario analysis (String, Hash, List, Set, Sorted Set)
  7. redis set expiration time
  8. Redis memory elimination mechanism (There are 2000w data in MySQL and only 20w data in Redis. How to ensure that the data in Redis are all hot data?)
  9. Redis persistence mechanism (how to ensure that the data can be restored after redis is hung up and restarted)
  10. redis transaction
  11. Redis common exceptions and solutions (cache penetration, cache avalanche, cache warm-up, cache degradation)
  12. Common application scenarios in distributed environments (distributed locks, distributed self-incrementing ID)
  13. Redis cluster mode (master-slave mode, sentry mode, Cluster cluster mode)
  14. How to solve Redis's concurrent competition Key problem
  15. How to ensure data consistency between the cache and the database when it is double-written?

 

Ten, JVM related

  1. How to judge whether an object is alive? (or how to judge GC objects)
  2. What are the methods of garbage collection in java?
  3. Briefly describe the java garbage collection mechanism?
  4. Two judgment methods for GC?
  5. When do Minor GC and Full GC happen respectively?
  6. Which areas are the JVM memory divided into, and what is the function of each area?
  7. What are the GC collectors? Features of CMS Collector and G1 Collector
  8. The three collection methods of GC: the principles and characteristics of mark removal, mark sorting, and copying algorithms. Where are they used? If you are asked to optimize the collection method, what ideas do you have?
  9. The class loader parent delegation model mechanism?
  10. java class loading process?
  11. Briefly describe the java class loading mechanism?
  12. What are class loaders and what are the class loaders?
  13. Briefly describe java memory allocation and recovery strategies, Minor GC and Major GC
  14. Exploring HotSpot Virtual Machine Objects
  15. HotSpot garbage collector

 

11. Tuning aspects

  1. 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?
  2. Will there be a memory leak in Java? Please describe briefly.
  3. If the object's reference is set to null, will the garbage collector immediately release the memory occupied by the object?
  4. When is the finalize() method called? What is the purpose of finalization?
  5. What is the difference between a serial collector and a throughput collector?
  6. What is distributed garbage collection (DGC)? How does it work?
  7. How do you tune tomcat?
  8. Tomcat's optimization experience
  9. In Java, when can an object be garbage collected?
  10. What will System.gc() and Runtime.gc() do?
  11. Will there be a memory leak in Java, please describe briefly
  12. What is GC? Why is there a GC?
  13. Will garbage collection occur in the permanent generation of the JVM?
  14. What kinds of connector operating modes (optimization) does tomcat have?
  15. Memory tuning

12. Design pattern

  1. The essentials of 21 design patterns
  2. Please list several commonly used design patterns in JDK?
  3. What is a design pattern? Have you used any design patterns in your code?
  4. What is the observer design pattern in Java?
  5. What are the main benefits of using the factory model? Where is it used?
  6. In Java, when do you use overloading and when do you use rewriting?
  7. In Java, why is it not allowed to access non-static variables from static methods?
  8. Design an ATM machine, please tell me your design ideas?
  9. Give a decorator design pattern implemented in Java? Does it act on the object level or the class level
  10. Give examples to illustrate when you would prefer to use abstract classes instead of interfaces?

Thirteen, algorithm & data structure

  1. How to reverse a stack with only recursive functions and stack operations?
  2. Divide the singly linked list according to a certain value into the form of small left, equal middle, and large right
  3. Recursively and non-recursively implement binary tree pre-order, middle-order and post-order traversal
  4. Recursion and dynamic programming of Fibonacci series of problems
  5. Determine whether any characters in the character array have only appeared once
  6. Find a string in an ordered but empty array
  7. Use only 2GB of memory to find the most frequent number among 2 billion integers
  8. The length of the longest sub-array whose cumulative sum is less than or equal to a given value in an unsorted array
  9. From 5 random to 7 random and its expansion
  10. The maximum value minus the minimum value is less than or equal to the number of num
  11. Joseph's Problem of Circular Singly Linked List
  12. Reverse the order between every K nodes of the singly linked list
  13. Find the longest path length whose cumulative sum is the specified value in the binary tree
  14. Determine whether a binary tree is a search binary tree or a complete binary tree
  15. Longest common subsequence problem

14. Concurrency

  1. What is reentrancy, and why is Synchronized a reentrant lock?
  2. Why is Synchronized a pessimistic lock? What is the realization principle of optimistic locking? What is CAS and what are its characteristics?
  3. Is optimistic locking necessarily good?
  4. What optimizations has JVM made to Java's native locks?
  5. How does ReentrantLock achieve reentrancy?
  6. Compared with Synchronized, how is the implementation principle of ReentrantLock different?
  7. How to synchronize the threads of Java with each other? What synchronizers do you know about? Please introduce them separately.
  8. CyclicBarrier and CountDownLatch look very similar, please compare?
  9. How are the threads in the thread pool created? Was it created at the beginning with the start of the thread pool?
  10. Since it is mentioned that different thread pools can be created by configuring different parameters, what thread pools are implemented by default in Java? Please compare their similarities and differences
  11. Please talk about the characteristics of volatile and why it can guarantee the visibility of variables to all threads?
  12. What is Java's memory model, and how does each thread in Java see each other's variables?
  13. Since volatile can guarantee the visibility of variables between threads, does it mean that operations based on volatile variables are and are safe?
  14. Many people say that ThreadLocal should be used with caution. Let’s talk about your understanding. What should I pay attention to when using ThreadLocal?
  15. Please talk about the AQS framework?

15. Operating system/Linux

  1. Causes of deadlock
  2. The difference between process and thread, when to use thread
  3. How to implement a thread pool, how to configure the thread pool in Java
  4. What are the common instructions in linux, introduce
  5. Have you learned about select, poll, and epoll? Explain
  6. Thread switching, extended to Java blocking ➡️run
  7. How to copy /home directory hierarchically to another directory?
  8. What is the minimum number of partitions required to install Linux, and how to view system startup information?
  9. How to pause a running process and put it in the background (not running)?
  10. What is a page fault and how does it happen?

At last

I have sorted out the answers to these questions and recorded them in this Java study note. This note includes Spring, JVM, Java basics, Java collections, Java concurrent programming, microservices, network, Kafka, distributed, Redis, Dachang Interview solutions, distributed transactions, design patterns, algorithms, data structures, MySQL, etc.

There are many details. In order not to affect reading, you can read the compiled "Java Architecture Advanced Notes". Each knowledge point has a left-side navigation bookmark page, which is very convenient to read. Due to the large amount of content, here is a screenshot. Right. Readers and friends who need it, just click the portal ! !

Guess you like

Origin blog.csdn.net/Java6888/article/details/115027511
Recommended