Are you dissatisfied with the "Java Interview Questions Manual" on the whole network? Come take a look!

Foreword:

This article collects and sorts out N common interview questions from major factories. Here are the content you want: Java, MyBatis, ZooKeeper, Dubbo, Elasticsearch, Memcached, Redis, MySQL, Spring, Spring Boot, Spring Cloud, RabbitMQ, Kafka , Linux and other technology stacks, I hope everyone can find a company that suits them and have a happy code.

One, 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 several 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? 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 highly concurrent 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 registration center continue to communicate after hanging 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 achieve 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?

Two, distributed

  1. Is the message retransmission interval and retransmission times in ActiveMQ?
  2. How to place partitions in different Brokers when Kafka creates Topic
  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. What are the advantages and disadvantages of memcached compared with the server's local cache (such as PHP APC, mmap files, etc.)?
  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 indexes?
  9. Does MongoDB support stored procedures? If so, 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 undefined server name to prevent request processing?
  12. Is there a limit on the number of messages stored in a queue on RabbitMQ?
  13. If the owner node of 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 is it that the condition to ensure that the message is reliably persisted is that the queue and exchange have durable attributes, and the message has persistent attributes?
  15. Why use cache, what cache have you used, the difference between redis and memcache?

 

Three, 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 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 SpringMvc's controller a singleton mode? If so, what is the problem and how to solve it?
  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 should 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 achieve 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?

 

Four, 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 thread starvation and what is livelock?
  5. Understanding and use of keywords for thread-safe operations such as atomicinteger and volatile
  6. What are volatile variables? 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. For the synchronization problem of communication between multiple threads, synchronized locks are objects, and there are many specific problems 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 variable 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 start() and run() directly
  13. Synchronous data structure, such as the source code understanding of concurrentHashMap and the internal implementation principle, 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 reaches the maximum? The underlying principle.

Five, the network

  1. Why 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. How does TCP solve the problem of packet loss caused by too high sending frequency?
  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. Where is HTTP
  9. HTTP message structure
  10. HTTP header field
  11. Which layer is HTTPs encryption implemented?
  12. http is stateless communication. What are the HTTP request methods? Can you define new request methods yourself?
  13. Socket communication, as well as long connection, sub-packaging, abnormal connection disconnection processing.
  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

Six, MySQL database

  1. Four major features (ACID) atomicity, consistency, isolation, and durability?
  2. What is the order in which the different elements of the query statement (where, jion, limit, group by, having, etc.) are executed?
  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 each level will cause, which level is MySQL by default?
  7. The difference between MySQL B+Tree index and Hash index?
  8. What locks are there (optimistic locks, pessimistic locks), and how to add exclusive locks when selecting?
  9. SQL query statement determines which type of index to create? How to optimize the query?
  10. The difference between clustered index and non-clustered index?
  11. What 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 questions about database read-write separation, master-slave replication, master-slave replication analysis?
  15. Transaction recovery mechanism (REDO log and UNDO log) when the database crashes?

Seven, 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 is hot data?)
  9. Redis persistence mechanism (how to ensure that the data can be restored after redis hangs and restarts)
  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-increasing ID)
  13. Redis cluster mode (master-slave mode, sentinel 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?

Eight, 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. JVM memory is divided into several areas, what is the role 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 the java memory allocation and recovery strategy and Minor GC and Major GC
  14. Exploring HotSpot Virtual Machine Objects
  15. HotSpot garbage collector

Nine, 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 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

 

Ten, design patterns

  1. Knowledge points 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. In Java, what is the observer design pattern (observer design pattern)?
  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?

11. 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 there are 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 sub-arrays 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

12. Concurrency

  1. What is reentrancy, and why is Synchronized a reentrant lock?
  2. Why is Synchronized a pessimistic lock? What is the 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, what is the difference in the implementation principle of ReentrantLock?
  7. How to synchronize Java threads 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 threads in the thread pool created? Was it created at the beginning with the thread pool started?
  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 do threads 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 concurrently safe?
  14. Many people say that ThreadLocal should be used with caution. Talk about your understanding, what should be paid attention to when using ThreadLocal?
  15. Please talk about the AQS framework?

13. 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?

The analysis of all the answers is as follows: (not one by one screenshots, all in the following section, all have been organized into these PDFs, private message me "interview" for free sharing)

The latest Java job interview list: distributed + Dubbo + thread + Redis + database + JVM + concurrency

Answer analysis

More Java-related notes

The latest Java job interview list: distributed + Dubbo + thread + Redis + database + JVM + concurrency

More Java-related notes

The answers have been sorted out, and there are more Java study notes here. It is easy to download all these PDFs. After one-click and three-connection, "Add me VX assistant" can get it for free!

 

Guess you like

Origin blog.csdn.net/a159357445566/article/details/109169525