Preface Jin SAN Yin Si has already been half, in terms of the current domestic interview mode, before the interview actively prepare for the interview, review the whole Java knowledge system will become very important, can be very responsible to say, review preparation is sufficient, will directly affect your success rate of entry.

But many of you don’t have the right materials to review your entire Java body of knowledge, or you may not know where to start.

Here we share 200+ questions and the free Java Foundation to Architecture interview answers document (PDF version), hoping to let the friends who are going through the interview to pick up the mistake, see the bottom

JAVA based

What are the basic data types in JAVA and how many bytes each takes up?

Can the String class be inherited? Why?

Stringbuffer StringBuilder.

What’s the difference between ArrayList and LinkedList?

Talk about the order in which classes are instantiated, like superclass static data, constructors, fields, subclass static data, constructors, fields, when new, the order in which they are executed.

HashMap is thread safe, what are the maps used concurrently, what are their internal principles, such as storage, Hashcode, capacity expansion, default capacity, etc.

JAVA8’s ConcurrentHashMap does not have a segmented lock, what is the question, if you design, how do you design.

Are there any sequential Map implementation classes, and if so, how do they ensure that they are ordered?

The difference between abstract classes and interfaces is that a class can inherit from multiple classes, an interface can inherit from multiple interfaces, and a class can implement multiple interfaces.

What’s the difference between inheritance and aggregation?

What are the IO models, what do you understand about NIO, how does it differ from BIO and AIO, and the REACTOR model.

How reflection works, what are the three ways that reflection creates class instances.

In reflection, class. forName is different from ClassLoader.

Describe several implementation methods of dynamic proxy and describe their advantages and disadvantages.

Differences between dynamic proxies and Cglib implementations.

Why CGlib can be used to implement proxies for interfaces.

The use of final.

Write out three singleton pattern implementations.

How do I automatically complete all hashCode and equals implementations for subclasses in a parent class? What are the pros and cons of this.

Talk about the role of access modifiers public, private, protected, and default in application design in the context of OO design.

Deep copy is different from shallow copy. Array and linked list data structure description, their time complexity.

Error and Exception, CheckedException, RuntimeException.

List five runtime exceptions.

If you create a java.lang.String class in your own code, can that class be loaded by the class loader? Why.

What is serialization, how to serialize, why serialization, deserialization will encounter what problems, how to solve.

New features in java8.

The JVM knowledge

What happens when a stack memory overflow occurs? JVM memory structure, Eden and Survivor ratio. JVM memory is divided into new generation, old generation, persistent generation. Why should the new generation be divided into Eden and Survivor? What does a complete GC flow look like in the JVM, how objects progress to the old age, and what are some of the main JVM parameters you know about? You know which garbage collectors, their pros and cons, focus on CMS and G1, including principles, processes, and pros and cons. The realization principle of garbage collection algorithm. When there is an overflow of memory, how do you sort it out. How much do you know about the JVM memory model, such as reordering, memory barriers, happening-before, main memory, working memory, etc. Tell me briefly what you know about classloaders, can they break parental delegation and how. Talk about Reflection in JAVA. What JVM parameters do you apply online? G1 and CMS differences, throughput first and response first garbage collector selection. How to print thread stack information.

Please explain what the following JVM parameters mean:

-server -Xms512m -Xmx512m -Xss1024K -XX:PermSize=256m -XX:MaxPermSize=512m - XX: XX: MaxTenuringThreshold = 20 CMSInitiatingOccupancyFraction = 80 - XX: + UseCMSInitiatingOccupancyOnly.Copy the code

Open source framework knowledge

A brief introduction to the Tomcat structure, its classloader flow, threading model, and more.

How tomcat is tuned and what parameters are involved.

Talk about the Spring loading process.

The implementation principle of Spring AOP.

Talk about the propagation properties of Spring transactions.

How Spring manages transactions.

How Spring configures transactions (specify some key XML elements).

What is your understanding of Spring? How does non-singleton injection work? Its life cycle? The principle of circular injection, aop implementation principle.

Talk about a few terms in AOP and how they work with each other.

Initialization of DispatcherServlet in Springmvc.

Netty’s threading model, how netty is implemented based on the REACTOR model.

Why netty?

What is TCP sticky packet? Unpack.

What is the solution. Usage of Netty’s FashwheelTimer, implementation principle, whether the call is not on time, how to solve.

Netty heartbeat processing in the weak network how to do.

What is the communication protocol of Netty?

Springmvc uses annotations, what they do, how they work.

Springboot boot mechanism.

The operating system

What kernel parameters do you care about in Linux? There are several IO models in Linux. What’s the difference between epoll and poll? Which Linux commands do you use? Look at the last five lines of the file with one command. Output the running Java process with a single command. Introduce your understanding of thread switching in an operating system. The difference between processes and threads. What comes after the top command and what does it do? The online CPU is high. How do you find the problem?

multithreading

Several ways to achieve multithreading, what is thread safety.

How volatile works, how it works, and how it replaces locking.

Draw a life cycle state diagram for a thread.

The difference between “sleep” and “wait”.

The difference between sleep and sleep(0).

The difference between Lock and Synchronized

What is the principle of synchronized, and where it is generally used (e.g. the difference between static and non-static methods, and does it matter if both methods are executed simultaneously),

Explain the following terms: reorder, spin lock, bias lock, lightweight lock, reentrant lock, fair lock, unfair lock, optimistic lock, pessimistic lock. Which atomic classes are used and how they work.

What concurrency tools have been studied under JUC? Explain the principle.

If you have used a thread pool, please explain how it works and explain the difference between newCache and newFixed. What is the meaning of each constructor parameter (coreSize, maxsize, etc.)?

There are several ways to close a thread pool, and what are the differences?

If you have a third-party interface that has many threads calling it to fetch data, you can now specify that at most 10 threads are calling it at the same time every second. Is the spring controller singleton or multi-instance? How to ensure the safety of concurrency?

Print the letters ABC in a sequence of three threads, such as abcabcabc. Have you used ThreadLocal before? What does it do? How does it work?

What would you do if you were asked to implement a concurrency safe linked list?

What lock-free data structures are there, and how they work.

Talk about Java synchronization mechanisms wait and notify.

What is CAS mechanism and how to solve ABA problem.

Multithreading what happens if the thread hangs.

The internals and usage of countdowlatch and cyclicBarrier, as well as the differences between them (such as the await method of countdownlatch and how it is implemented).

To understand AbstractQueuedSynchronizer, something about locking and unlocking process, what’s the difference between an exclusive lock and lock by fair.

What is the difference between using synchronized to modify static and non-static methods?

Briefly describe the uses and differences of ConcurrentLinkedQueue and LinkedBlockingQueue.

What causes thread deadlocks?

How to unlock a thread deadlock.

Many threads (possibly different machines) need to wait for coordination between each other to complete some kind of work.

Have you used read/write lock? What is the principle? What is the general situation?

Open multiple threads, if ensure sequential execution, what are the implementation methods, or how to ensure that multiple threads are executed before getting results.

The implementation of delayQueue, delayQueue and time round algorithm similarities and differences.

TCP and HTTP

What’s the difference between HTTP1.0 and HTTP1.1?

TCP three-way handshake and four-way wave. Why does it take four times to disconnect? What happens if there are only two handshakes?

Difference between TIME_WAIT and CLOSE_WAIT

Name several HTTP response codes you know, such as 200, 302, 404.

When you open a link with your browser (e.g.www.javastack.cn), what steps the computer does.

How to ensure TCP/IP reliability, talk about the structure of the TCP header.

2 How to avoid browser caching.

How to understand the statelessness of HTTP protocol.

This section describes the differences between GET and POST and the packet formats of Http requests.

Methods of HTTP Describes the format of HTTP request packets.

HTTP long connection. What is the encryption method of HTTPS? Explain the whole encryption and decryption process.

What’s the difference between Http and HTTPS’s three-way handshake?

What is chunking?

The difference between Session and cookie.

Architectural design and distribution

Implement an LRU yourself in Java.

How to achieve unique sequence number in distributed cluster.

How to use Redis and ZooKeeper to implement distributed locks? What are the differences? What are the advantages and disadvantages? What are the problems? (Extension: If you know About Redlock, talk about its algorithm implementation, where is the dispute) If someone creates an illegal connection maliciously, how to resolve.

The principle of distributed transaction, advantages and disadvantages, how to use distributed transaction, the difference between 2PC and 3PC, which problems solved, which problems are not solved, how to solve, your own project involves how to deal with distributed transaction.

What is a consistent hash?

What is restful? Tell me what you understand restful.

How to design a good API.

How to design and establish and maintain 100W long connections.

Explain what the MESI protocol (cache consistency) is.

Name some HASH algorithms you know, even simple ones.

What is paxOS algorithm and what is ZAB protocol?

An online document system, documents can be edited, how to prevent multiple people from editing and updating the same document at the same time.

Online systems suddenly become incredibly slow, how do you find problems.

Tell me about a design pattern you use.

Dubbo principle, have read the source code, how data flow, how to achieve clustering, load balancing, service registration and discovery, retry forwarding, fast failure strategy is what.

What is the flow of an RPC request?

Have you implemented RPC? The principle can be explained briefly.

What problem does Rpc solve?

The purpose and significance of asynchronous patterns.

How to consider some design principles in programming, such as the open and close principle, and the application in the work.

Design a “private message” feature in a social networking site that requires high concurrency, scalability, etc.

Draw the architecture diagram.

The MVC pattern is the common MVC framework.

I will talk about the server architecture I participated in designing and drawing, and the problems I met and how to solve them.

How the application server monitors performance, the difference in various ways.

How to design a high concurrency payment solution, how to design the architecture.

How to achieve load balancing and what algorithms can be implemented.

What Zookeeper is used for and how elections work.

Mechanism of Zookeeper Watch.

The underlying realization principle of Mybatis.

Consider a solution to implement countDownLatch in a distributed environment.

How does the backend system prevent requests from being submitted repeatedly?

Describes the detailed process of a service from publication to consumption.

Describe your understanding of service governance.

How to make interfaces idempotent.

How to do traffic limiting policy, the use of token bucket and funnel algorithm scenarios.

What is data consistency? How do you understand data consistency?

Distributed services the caller, don’t rely on the service provider, how to deal with service party after hanging up, a large number of invalid waste of resource requests, if only the provider do throughput is not high, if the service hang up and then restart after a while, how to do the smallest resource waste, traffic half-opened implementation mechanisms.

How dubbo’s generalization calls are implemented, and what you would do if it were you.

Remote call will have timeout phenomenon, if you do elegant control, JDK built-in timeout mechanism what, how to implement.

algorithm

Find the 10 smallest numbers in a billion.

There are 100 million numbers, two of which are repeated, and find it quickly, in time and space.

200 million randomly generated, unordered integers, find the middle size of the value.

Given an input string of unknown length (possibly large), devise a scheme for reweighting duplicate characters.

Walk through the binary tree.

There are 3n+1 numbers, 3n of which are repeated, and only 1 of which is not repeated.

Write a string (for example:www.javastack.cn) reverse the function.

Commonly used sorting algorithm, quick sorting, merge, bubble.

The optimal time complexity and the worst complexity of fast sorting.

Optimization scheme of bubble sort.

Time complexity of binary search, advantages.

How to reverse sort a TreeSet that is already built.

What are B+ trees, B- trees, list the actual usage scenarios.

A one-way linked list, delete the last NTH data.

200 ordered arrays of 100 elements each, find the top20 elements.

One-way linked list, looking for the element in the middle.

Database knowledge

What are the database isolation levels, what are their meanings, and what is MYSQL’s default isolation level?

What is illusory.

What storage engines does MYSQL have?

How to safely modify the same row of data under high concurrency.

What are optimistic locks and pessimistic locks? What are INNODB’s standard row-level locks? Explain their meanings.

What are the general steps of SQL optimization, how to look at the execution plan, and how to understand the meaning of each field in it?

Mysql > mysql > deadlock > mysql > mysql > deadlock

MYsql index principle, index types, how to create a reasonable index, index optimization.

Differences between clustered and non-clustered indexes.

Select for update, lock table, lock row, etc.

Why Btree is implemented, how it splits, when it splits, and why it’s balanced.

What is the ACID of the database?

A table has nearly ten million data, CRUD is relatively slow, how to optimize.

Mysql optimize table scan.

How to write SQL to effectively use composite indexes.

In and exists are different in mysql.

Possible problem with database auto-increment primary key.

What MVCC means and how it is implemented.

Have you met the sub-database and sub-table in the projects you have done? How to do it? Is it used for middleware, such as Sharding JDBC, etc., and do you know their principle?

How to solve the primary/secondary delay of MYSQL?

The message queue

Usage scenarios for message queues.

Retransmission of messages, supplementary policies.

How to ensure the order of messages.

What MQ has been used, what are its advantages and disadvantages compared to other MQS, are MQ connections thread safe, and what is your company’s MQ service architecture?

How to ensure that data in the MQ system is not lost?

How rabbitMQ implements cluster high availability.

The reason for kafka’s high throughput.

The difference between Kafka and other message queues is how kafka master slave synchronization is implemented.

How to achieve final consistency with MQ.

Have you encountered any problems with Kafka? What are the solutions?

Repeated consumption of MQ may occur, how to avoid it, and how to achieve idempotent.

MQ messages delayed how to deal with, can the message set expiration time, expired you generally how to deal with.

The cache

What are the common cache strategies? How to make the cache (such as Redis) consistent with the data in DB? What is the cache system used in your project?

How to prevent cache crashes and avalanches.

How to design updates to cache data after expiration.

Redis list structure-related operations.

What are the data structures of Redis?

Redis: Persistence, memory Settings, clustering applications, advantages and disadvantages, elimination strategies, etc.

The difference between REDIS2 and Redis3, redis3 internal communication mechanism.

The current redis cluster has what gameplay, their advantages and disadvantages, scenarios.

How Memcache works, what data fits in the cache. Memory management differences between Redis and memcached.

How to solve the problem of Redis concurrency contention, understand the CAS operation of Redis transaction?

What is the Redis election algorithm and process?

Redis persistence mechanism, aOF and RDB difference.

How the redis cluster synchronizes data.

Know which redis optimization operations.

Principle of master/slave replication mechanism for Reids.

What is the thread model of Redis?

Consider a scenario for designing an adaptive local cache that can control the overall size of the cache.

How to view the use of caches (local caches, centralized caches), briefly describe the advantages and disadvantages of local and centralized caches.

Precautions for concurrent use of local cache.

search

How many shards are there, how many are there, and how many tuning methods are there? What is the inverted index of ElasticSearch? Select * from elasticSearch; select * from elasticSearch; How does ElasticSearch implement master voting? Describe the process of indexing documents for Elasticsearch in detail. Describe the process of Elasticsearch in detail. What are the optimizations for Linux Settings when Elasticsearch is deployed? What is the internal structure of Lucence? I don’t know whether it will fail, if it fails, click (723770387) or scan the following TWO-DIMENSIONAL code to get the group, the link does not fill, I hope you can understand, but also can learn more with you

Link: Web disk

Extraction code: Pexe