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.
- Describe your understanding of the hashCode and equals methods in java.lang.Object. Under what circumstances
- Both methods need to be reimplemented.
- In jdk1.5, generics were introduced to solve what problems generics exist to solve.
- What’s the use of this a.hashcode()?
- Is it possible that two objects that are not equal have the same Hashcode?
- How a HashSet in Java works internally.
- 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 is the complete GC flow in the JVM? How does an object progress to older generations? What are the main JVM parameters that you know of
- The number.
- 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.
- Knowledge of the JVM memory model, such as reordering, memory barriers, happening-before, main memory, work
- 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:MaxTenuringThreshold=20XX:CMSInitiatingOccupancyFraction=80 –
- XX: + UseCMSInitiatingOccupancyOnly.
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? Cyclic injection principle, aop implementation of the original
- Let’s 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.
- Click here for a Spring exam with answers.
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 is it generally used (e.g. the difference between static and non-static methods, static
- Does it matter when static and non-static methods are executed simultaneously?), explain the terms: resort, spin lock, bias lock, light
- Weight 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.
- Have you used a thread pool? If so, explain how it works and what is the difference between newCache and newFixed
- What are the meanings of the various parameters of the number, such as 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 to call to fetch data, you can now specify a maximum of 10 lines per second
- Call it when, how to do.
- 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 uses of countdowlatch and CyclicBarrier, and the differences between them (e.g
- Countdownlatch ‘await’ method and how it is implemented.
- To understand AbstractQueuedSynchronizer, something about locking and unlocking process, an exclusive lock and fair
- What’s the difference with locking.
- 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?
- If multiple threads are enabled, if sequential execution is guaranteed, what are the implementation methods, or how to ensure that multiple threads are completed
- And get the results.
- The implementation of delayQueue, delayQueue and time round algorithm similarities and differences.
- Click here for a set of multi-threaded questions with answers.
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.
- What steps does the computer take when you open a link (such as www.javastack.cn) with your browser?
- How to ensure TCP/IP reliability, talk about the structure of the TCP header.
- 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.
- HTTP methods
- This section 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.
- Click here for a set of questions with answers.
Architectural design and distribution
- Implement an LRU yourself in Java.
- How to achieve unique sequence number in distributed cluster.
- Design a split-kill system that automatically closes transactions if no payment is made in 30 minutes.
- How to use Redis and ZooKeeper to implement distributed locks? What are the differences? What are the advantages and disadvantages? What are the problems
- Scenario. (Extension: If you know Redlock, talk about his algorithm implementation, where is the controversy?)
- What can I do if an invalid connection is created maliciously?
- The principle of distributed transaction, advantages and disadvantages, how to use distributed transaction, the difference between 2PC and 3PC, what problems solved, and
- What issues are not addressed, how are they addressed, and how are distributed transactions handled in your own projects?
- 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?
- In an online document system, documents can be edited. How do you prevent multiple people from working together at the same time
- A document for editing and updating.
- 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 cluster, load balancing, service registration
- And what are the strategies for discovering, retrying forwarding, and failing fast.
- 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?
- How does a distributed service caller, independent of the service provider, handle a large number of invalid resource requests when the service provider hangs up
- Waste, if only the service provider throughput is not high what to do, if the service is down, then later restart, what to do
- What is the realization mechanism of half-open flow to minimize resource waste?
- 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 (e.g. www.javastack.cn) to reverse the function.
- Commonly used sorting algorithm, quick sorting, merge, bubble. The optimal time complexity and the worst complexity of fast sorting. Bubble sort
- Optimize the scheme.
- 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.
- Did you meet the sub-database sub-table in the project you have done, how to do it, is it useful for middleware, such as Sharding JDBC, he
- Do you know how they work?
- 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 MQS have you used, what are the advantages and disadvantages compared to other MQS, are MQ connections thread safe, your company’s MQ service
- What’s the 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, and how to ensure that the cache (such as Redis) is consistent with the data in DB, which were used in your project
- What caching system? How it was designed.
- 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
- The size of the index data, how many shards there are, and some
- Tune the means. 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?
These are the most comprehensive Java interview questions, and the following are the latest summary of Java interview questions and answers.
2020 Latest BAT advanced Java interview questions and answers
Claim Method:
Attention + forward, get the answer!
Important things say three times, forward, forward, forward after attention can get oh!