Recently may be a little idle panic, nothing to look for an interview, sorted out a wave of questions. I roughly divided into Java basic, intermediate, advanced, distributed, Spring architecture, multi-threading, networking, MySQL, Redis cache, JVM related, tuning, design patterns, algorithms and data structures, concurrency, Linux and so on 15 small modules.

Each module essay should probably only give part of the interview questions, otherwise there won’t be enough space to write all of them. And there are corresponding answers, too difficult, so directly to provide you with the most complete answer analysis document

Link: Stamp here free download, get code: nuggets

First, Java foundation

  1. What is the main class of a Java program? What is the difference between the main class of an application and a applet?
  2. Can the Constructor be override?
  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’s the difference between overloading and overwriting?
  6. Why is it illegal to call a non-static member in a static method?
  7. Introduce 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 a return value in a class method?
  9. What does a class constructor do If a class does not declare a constructor, does the program execute correctly? Why is that?
  10. Three major features of Java object-oriented programming: encapsulation inheritance polymorphism
  11. What if there are fields in Java serialization that you don’t want to serialize?
  12. The subclass constructor is called before the subclass constructor is called.
  13. What are the basic states of a thread?
  14. What operator is used to create an object? How is an object entity different from an object reference?
  15. What is the difference between a member variable and a local variable?

Second, Java Intermediate

  1. What are AOP and IOC in Spring? What are the usage scenarios? Spring transactions, transaction properties, database isolation levels
  2. What are the annotations for Spring and SpringMVC, MyBatis and SpringBoot?
  3. What are the SpringCould components and what do they do? What is the CAP of microservices? What is BASE?
  4. The basic implementation principle of HashMap, red-black tree, B+ tree, structure principle of B tree, CAS (comparison and exchange) implementation principle
  5. Redis supports data types and usage scenarios, persistence, sentry mechanism, cache penetration, cache penetration
  6. What is a thread, there are several ways to implement it, what is the difference between them, thread pool implementation, JUC and packet
  7. Security issues (data tampering (get someone’s URL, tamper with data (amount) and send it to the system))
  8. Constraints on index use, what SQL optimizations are, data synchronization issues (caching, database data synchronization)
  9. Distributed transaction
  10. Heap overflow, stack overflow occurrence scenarios and solutions
  11. What are pessimistic locks, optimistic locks, read-write locks, row locks, table locks, spin locks, deadlocks, distributed locks, thread synchronous locks, fair locks, and unfair locks?
  12. There are several steps to initialize a Bean object and its life cycle
  13. JVM memory model, algorithm, garbage collector, tuning, class loading mechanism (parent delegate), creating an object, how is this object allocated in memory?
  14. Dubbo operating principle, compared with SpringCould, why it is more efficient, the underlying principle of Zookeeper
  15. Name the differences between several TYPES of MQ and why messages are sent repeatedly (idempotence), messages fail to be sent, messages are switched, messages are not received for a long time, messages are sent too large to be received successfully

Java advanced

  1. Why message queues? What are the advantages and disadvantages of message queues? What are the advantages and disadvantages of Kafka, ActiveMQ, RabbitMQ, and RocketMQ?
  2. How to ensure that messages are not re-consumed? In other words, how can message consumption be idempotent?
  3. How to solve message queue delay and expiration problem? What happens when the message queue is full? There are millions of messages waiting for hours. How do you fix them?
  4. Can you explain how redis cluster mode works? How is redis key addressed in clustered mode? What are the algorithms for distributed addressing? Do you know consistent hash algorithms?
  5. What is redis avalanche, penetration and breakdown? What happens when Redis crashes? How does the system deal with this? How to handle redis penetration?
  6. Why separate tables and databases (how to design the database level when designing a high concurrency system)? Which sub-database sub-table middleware have you used? What are the advantages and disadvantages of different sub-database and sub-table middleware? How exactly do you split the database vertically or horizontally?
  7. Do you have MySQL read-write separation? How to implement MySQL read-write separation? How does MySQL master slave replication work? How to solve the delay of MySQL master/slave synchronization?
  8. How does Dubbo work? Can I continue communication when the registry is down? Describe the flow of an RPC request.
  9. How to dubbo service governance, service degradation, failed retry, and timeout retry?
  10. How to implement distributed session in cluster deployment?
  11. What do I mean by service registration and discovery? How is Spring Cloud implemented?
  12. What are the general ways to implement distributed locks? How to design points using Redis
  13. Cloth type lock? Is it possible to design distributed locks using ZK? Which of the two distributed locks is more efficient?
  14. What is Dubbo’s SPI idea?
  15. How to design a scheme for dynamically expanding and shrinking the database and table?

Four, distributed

  1. Is the message retransmission interval and number of retransmissions in ActiveMQ?

  2. How does Kafka place partitions into different brokers when creating topics

  3. What two conditions does Kafka have to determine if a node is still alive?

  4. Are Kafka messages in Pull mode or Push mode?

  5. How does memcached compare to a server’s local cache, such as PHP APC, Mmap files, etc.?

  6. I need to export and import items from memcached. What do I do?

  7. What are threads in Memcached? How to use them?

  8. A:{B,C} A:{B,C} A:{C,B} A:{C,B}

  9. Does MongoDB support stored procedures? If so, how to use it?

  10. How to understand the GridFS mechanism in MongoDB and why MongoDB uses GridFS to store files?

  11. How can an undefined server name be used in Nginx to prevent requests from being processed?

  12. Is there a limit to how many messages can be stored in a queue on RabbitMQ?

  13. If the owner node of a queue in a cluster fails and the queue is declared as durable, can the queue be declared again on other nodes?

  14. Why queues and Exchanges must be durable and messages must be persistent?

  15. Why cache? Which caches are used? What is the difference between Redis and memcache?

5. Spring Architecture

  1. What is the difference between Spring Boot, Spring MVC and Spring?
  2. What’s the difference between BeanFactory and ApplicationContext?
  3. What is the Java-based Spring annotation configuration? Give some examples of annotations.
  4. Explain the life cycle of Spring beans?
  5. Are singleton Beans in the Spring framework thread-safe?
  6. Is SpringMvc’s controller a singleton? If so, what’s wrong with it and how to fix it?
  7. How does SpringMVC set up redirection and forwarding?
  8. What happens when a method returns special objects, such as objects, lists, etc., to AJAX?
  9. What object does SpringMvc use to pass data from the background to the foreground?
  10. What do I mean by service registration and discovery? How is Spring Cloud implemented?
  11. What are the advantages of using Spring Cloud?
  12. What is Hystrix circuit breaker? Do we need it?
  13. What is Spring Cloud Bus? Do we need it?
  14. How can Spring Boot applications be secured?
  15. The default H2 database name for the Spring Boot configuration is above? Why is the default database name testdb?

6. Threading

  1. Why are the stop() and suspend() methods not recommended?
  2. What are the similarities and differences between synchronous and asynchronous, and when are they used separately?
  3. Interthread communication, Wait and notify
  4. What is thread starvation and what is live lock?
  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 accesses a synchronized method of an object, can other threads access other synchronized methods of the object?
  8. Briefly synchronized and Java. Util. Concurrent. The locks. The similarities and differences between the Lock?
  9. Synchronization of communication between multiple threads, synchronized lock is the object, derived from a lot of specific issues related to synchronized, such as the same class different methods have synchronized lock, whether an object can be accessed at the same time. Or the effect of a class’s static constructor plus synchronized locks.
  10. What guarantees do volatile variables provide? Can a non-atomic operation be turned into an atomic operation?
  11. Learn about ReentrantLock and the difference between ReentrantLock and synchronized
  12. Java calls the difference between the start() method and run() method directly after a thread is created
  13. Synchronous data structures, such as concurrentHashMap source code understanding and internal implementation, why is it synchronous and efficient
  14. Common thread pool patterns and usage scenarios for different thread pools
  15. NewFixedThreadPool What happens to this thread pool if the number of threads reaches its maximum.

Seven, network aspect

  1. Why three handshakes
  2. What’s wrong with the second handshake
  3. What are the drawbacks of the three-way handshake
  4. How does TCP control traffic
  5. How does TCP solve the problem of packet loss caused by the sender sending too many packets
  6. Why use symmetric encryption and asymmetric encryption over HTTPs? What are the advantages of using asymmetric encryption only
  7. Talk about the OSI network architecture
  8. What layer is HTTP at
  9. HTTP packet Structure
  10. HTTP header field
  11. At what layer is HTTPs encryption implemented
  12. HTTP is stateless communication. What are the HTTP request methods? Can you define new request methods by yourself?
  13. Socket communication, and long connection, subcontracting, connection abnormal disconnection processing.
  14. Use of socket communication model, AIO and NIO.
  15. The use of socket framework NetTY, as well as NIO implementation principle, why is asynchronous non-blocking

MySQL database

  1. Atomicity, consistency, isolation, durability?
  2. The order in which different elements (WHERE, jion, limit, group by, Having, and so on) are executed?
  3. MySQL storage engine InnoDB, MyISAM, MEMORY
  4. MySQL MyISAM and InnoDB two storage engines in, transaction, lock level, their applicable scenarios?
  5. Mysql High concurrency environment solution?
  6. Concurrency of transactions? Transaction isolation levels, what problems are caused by each level, which level is MySQL’s default?
  7. MySQL > alter table B+Tree Hash index
  8. What locks (optimistic locks pessimistic locks), select how to add an exclusive lock?
  9. What type of index does the SQL query determine to create? How to optimize queries?
  10. What is the difference between a clustered index and a non-clustered index?
  11. Mysql > select * from ‘mysql’ where deadlock is determined
  12. Non-relational database and relational database differences, advantages comparison?
  13. MySQL > slow query
  14. Read/write separation, master-slave replication, master-slave replication analysis of databases
  15. What are the recovery mechanisms for transactions in the event of a database crash (REDO and UNDO logs)?

Redis cache

  1. What are redis transaction related commands?
  2. Why Redis/Why cache (high performance, high concurrency)
  3. Why redis and not Map/Guava?
  4. The difference between Redis and memcached
  5. Please introduce the data type SortedSet(Zset) of Redis and the underlying implementation mechanism.
  6. Redis common data structures and usage scenario analysis (String, Hash, List, Set, Sorted Set)
  7. Redis sets the expiration time
  8. Redis memory flushing mechanism (MySQL has 2000W data, redis only 20W data, how to ensure that redis data is hot data?)
  9. Redis persistence mechanism (how to ensure that redis hangs and then restarts data can be recovered)
  10. Redis transactions
  11. Redis common exceptions and solutions (cache penetration, cache avalanche, cache warming, cache degradation)
  12. Common application scenarios in distributed environment (distributed lock, distributed auto-increment ID)
  13. Redis Cluster mode (master-slave mode, Sentinel mode, Cluster mode)
  14. How to solve the Redis concurrent competing Key problem
  15. How to ensure data consistency between the cache and the database in dual write?

10. JVM related

  1. How do you tell if an object is alive? (or GC object determination method)
  2. What are the methods of garbage collection in Java?
  3. How about Java garbage collection?
  4. Two kinds of determination methods of GC?
  5. When does the Minor and Full GC occur?
  6. How many partitions are there in the JVM memory, and what does each partition do?
  7. What are the GC collectors? Features of CMS collector and G1 collector
  8. What are the principles and characteristics of GC’s three collection methods: tag clearing, tag collation and copy algorithm? What are your thoughts on how to optimize the collection method?
  9. Class loader parent delegate model mechanism?
  10. Java class loading process?
  11. What is the Java class loading mechanism?
  12. What is a class loader, and what are class loaders?
  13. Briefly describe the Java memory allocation and reclamation strategy and the Minor and Major GC
  14. HotSpot VIRTUAL machine object Exploration
  15. HotSpot garbage collector

Eleventh, tuning

  1. What is the rationale behind the garbage collector? Can the garbage collector reclaim memory right away? Is there any way to proactively notify the virtual machine for garbage collection?

  2. Is there a memory leak in Java? Please describe it briefly.

  3. If a reference to an object is set to NULL, does the garbage collector immediately free 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 optimization experience

  9. When can objects be garbage collected in Java?

  10. What do system.gc () and Runtime.gc() do?

  11. Is there a memory leak in Java? Please describe it briefly

  12. What is GC? Why GC?

  13. Does garbage collection occur in JVM permanent generations?

  14. What are the tomcat Connector operating modes (optimizations)?

  15. Memory tuning

Xii. Design mode

  1. 21 design pattern knowledge points
  2. Please list some common design patterns in the JDK.
  3. What are design patterns? Do you use 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 overwriting?
  7. In Java, why are non-static variables not allowed to be accessed from static methods?
  8. Design an ATM machine, please tell your design idea?
  9. What is a decorator design pattern implemented in Java? Does it work at the object level or the class level
  10. Give an example of a situation where an abstract class is preferred over an interface?

Algorithms & Data Structures

  1. How do I reverse a stack using only recursive functions and stack operations?
  2. Divide a one-way linked list into the form of small on the left, equal in the middle, and large on the right
  3. The first order, middle order and last order traversal of binary tree are realized in recursive and non-recursive ways respectively
  4. Recursion and dynamic programming for Fibonacci series problems
  5. Check if any characters in the array appear only once
  6. Finds a string in an ordered but empty array
  7. Use only the 2 billion integers in 2GB to find the most frequent number
  8. The maximum array length in an unsorted array whose sum is less than or equal to the given value
  9. From 5 random to 7 random and its extension
  10. The number of subarrays whose maximum minus minimum is less than or equal to num
  11. Joseph’s problem for circular singly linked lists
  12. Reverse the order between each K nodes of a singly linked list
  13. Finds the longest path length whose summation 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

Xiv. Concurrency

  1. What is reentrant and why is Synchronized reentrant?
  2. Why is Synchronized a pessimistic lock? What is the implementation principle of optimistic lock? What is CAS and what are its features?
  3. Is optimism lock necessarily good?
  4. What optimization has the JVM made to Java’s native locking?
  5. How does ReentrantLock achieve reentrancy?
  6. How is ReentrantLock implemented differently than Synchronized?
  7. How do I synchronize Java threads with each other? What synchronizers have you learned about? Please introduce them separately.
  8. CyclicBarrier and CountDownLatch look very similar.
  9. How are threads created in a thread pool? Was it created initially with the start of the thread pool?
  10. Since you can create different thread pools by configuring different parameters, what are the default thread pools implemented in Java? Please compare their similarities and differences
  11. Talk about what is special about volatile, and why it makes variables visible to all threads?
  12. What is the Java memory model, and how do threads in Java see each other’s variables?
  13. Since volatile guarantees variable visibility between threads, does that mean that operations based on volatile variables are safe?
  14. When using ThreadLocal, you need to be careful.
  15. What is the AQS framework?

15. Operating system /Linux

  1. Cause of deadlock
  2. What is the difference between a process and a thread
  3. How to implement a thread pool and how to configure it in Java
  4. This section describes the common commands in Linux
  5. Select, poll, epoll
  6. Thread switching, extended to Java blocking ➡️ runs
  7. How do I layer copy /home directories to another directory?
  8. What is the minimum number of partitions required to install Linux, and how do I view system boot information?
  9. How do I pause a running process and put it in the background (not running)?
  10. What is a page error and how does it happen?