Brushed the Java interview questions for more than half a year: finally got many offers from major manufacturers! Share a wish

Preface

Today, I will share with you the Java architecture interview topics and answers I have compiled. Most of them are frequently asked interview questions for large companies. You can check the omissions and fill in the vacancies. Of course, the list here must not cover all the methods.

Many Java developers may not have long working hours or rich work experience before the interview, so I don’t know what questions Internet companies or first-line Internet companies will ask in technical interviews? In addition, I may not have prepared enough. I was overwhelmed by a few questions by the interviewer within a few rounds of the interview, and ended up in a disastrous defeat. For these readers and friends, the editor has compiled some of the interviews of well-known big companies, and shared them here for readers and friends for reference, so that readers who are about to interview or have ideas to change jobs will understand those who like to ask during interviews with first-line big companies. problem.

Start (some questions have no reference answers, you need to come down and learn one by one!)

BAT frequently asked Java basics 39 common interview questions

1. The size of the eight basic data types, and their package classes

2. Reference data types

3. Can Switch use string as parameter

4. The difference between equals and ==

5. Automatic boxing, constant pool

6. What are the public methods of Object

7. Four references of Java, strong and weak, and the scenes used

8. The role of Hashcode

9. The role of hashcode of HashMap

10. Why overload the hashCode method?

11. The difference between ArrayList, LinkedList and Vector

12. The difference between String, StringBuffer and StringBuilder

13. Features and usage of Map, Set, List, Queue, Stack

14. The difference between HashMap and HashTable

15. Implementation of HashMap in JDK7 and JDK8

16. The difference between HashMap and ConcurrentHashMap, the underlying source code of HashMap

17. Can ConcurrentHashMap completely replace HashTable?

18. Why HashMap is not thread safe

19. How to use HashMap thread-safely

20. Will HashMap still produce an endless loop in the case of multiple concurrency?

21. The difference between TreeMap, HashMap, LindedHashMap

22. Collection package structure, the difference with Collections

23. try? catch? finally, there is return in try, is finally executed?

24.Excption and Error packet structure, what situations have you encountered in OOM, and what situations have you encountered in SOF

25. Java (OOP) object-oriented three characteristics and meanings

26. The meaning of Override and Overload to distinguish

27. The difference between Interface and abstract class

28. The difference between Static?class? and non?static?class

29. Foreach and normal for loop efficiency comparison

30. Java? IO given NIO

31. The role of java reflection principle

32. Common features of generics

33. Principles and characteristics of several ways of parsing XML: DOM, SAX

34. Java 1.7 and 1.8, 1.9, 10 new features

35. Design patterns: singleton, factory, adapter, chain of responsibility, observer, etc.

36. Use of JNI

37. What is AOP

38.What is OOP

39. The difference between AOP and OOP

Ant Financial (three sides)

Zookeeper + microservices + message middleware + high concurrency architecture design

one side

  1. JVM data storage model, the structure of the new generation and the old generation?

  2. Java GC algorithm, when will minor gc be triggered and when will full gc be triggered?

  3. Which of the GC reachability analysis is considered GC ROOT?

  4. JVM tuning parameters you are familiar with, and which tuning tools have you used?

  5. What types of locks does Java have?

  6. Describe the processing flow of the thread pool?

  7. Class loading mechanism. There are several steps for loading a class into the virtual machine. Which of these steps are fixed in order, which is not fixed, and why not?

  8. Hashmap is not thread-safe, and concurrenthashmap is thread-safe. How to achieve thread-safety?

  9. What problem does the volatile keyword solve and what is the principle of implementation?

  10. What are the concurrent containers and the difference between concurrent and synchronous containers

Two sides

  1. At work, the optimization of SQL statements and matters needing attention

  2. Which libraries or frameworks use NIO

  3. What kinds of injection methods does Spring have, which ones to use under what circumstances, and the principle of ioc implementation

  4. How to locate a slow query, how do you quickly locate a service with multiple SQL

  5. Do you know clustered index and non-clustered index? When to use a clustered index and what to use a non-clustered index

  6. What storage structure does Nosql engine use, what are the advantages and disadvantages of relational database and NoSQL, and how to select the technology?

  7. Under the microservice architecture, if there is an order system and an inventory system, how to guarantee transactions?

  8. Distributed consensus protocol raft, do you understand paxos

  9. ZAB protocol in Zookeeper, main selection algorithm

Three sides

  1. Self introduction

  2. Participate in concurrent projects, from design to deployment, follow the process to repeat.

  3. You have used redis for project-related purposes. In what scenarios and how did you use it?

  4. The principle of mysql synchronization mechanism, what are the synchronization methods

  5. How to realize database master-slave synchronization and how to realize transactions

  6. Talk about your understanding of SOA and microservices, as well as the adjustments and challenges involved in distributed architecture from the application level.

  7. What are the similarities and differences between Ali-based middleware metaQ and its principles and existing Kafka

  8. Do you know any middleware in Ali? Implementation principle? What are the characteristics of other open source message queues?

  9. Why choose to change company?

  10. Career planning for three to five years?

  11. Do you want to ask me?

Tmall (four sides)

Pressure test + Mina + transaction + cluster + spike architecture

one side

  1. The difference and applicable scenarios of common collections

  2. What do concurrent containers know?

  3. How to judge whether the linked list has a ring

  4. How to implement concurrentHashMap

  5. How cluster servers share application

  6. JAVA network programming: the difference and connection between BIO, NIO and AIO

  7. Jvm memory model jmm knows all about

  8. JAVA garbage collection, the difference between the marking algorithm and the copy algorithm, what occasions are they used for?

  9. The difference between http and https, the difference between http1.x and http2.0, the difference between SSL and TSL

  10. The difference between GC, G1 and ZGC

  11. The difference between B+ tree and B tree, and the difference between red and black trees

  12. The difference between memory leak and memory overflow

  13. How long is the life cycle of the session

  14. How much do you know about the Mina framework? (Because I used Mina in the project, I mentioned this part)

Two sides

  1. java cas principle

  2. What are the parameters of the JAVA thread pool, and what issues should be considered if you design a thread pool by yourself?

  3. The underlying implementation of Java's lock?

  4. What are the advantages of mysql database default storage engine

  5. MySQL's transaction isolation level, what problems are solved respectively.

  6. Four tables record grades, each with about 100,000 records, how to find the students with the best grades

  7. What are the common load balancing algorithms

  8. If Redis has 100 million keys, will using the keys command affect online services?

  9. Redis persistence methods, aod and rdb, how to implement it, append logs and backup files, do you know the underlying implementation principle?

Three sides

  1. Please draw a distributed server cluster deployment diagram of a complete large-scale website

  2. Multiple RPC requests come in, how does the server handle concurrency?

  3. Talk about the sentinel mechanism of Redis

  4. How much data does the database sub-database sub-table generally need?

  5. How to ensure that the database is consistent with the redis cache

  6. How is the message queue used in the project? What specific business scenarios are used?

  7. Which JVM-related analysis tools have you used? Are there specific performance tuning steps?

  8. How to do MySQL slow sql optimization in general? Besides, what other methods are there to optimize?

  9. Online server monitoring indicators, which indicators do you think need the most attention? why?

  10. How to do stress testing, anti-stress methods

  11. How to design the spike module

HR face

  1. Self introduction

  2. How would you rate your previous 3 interviews

  3. What do you think of yourself, what is your biggest core competitiveness

  4. Future career plan

  5. What kind of understanding of Ali's technology atmosphere, and which Ali's open source libraries have been used

  6. What is the expected salary

  7. Finally, what do you want to know

Comment on "Interview" at the end of the article: Add assistant VX: MXW5308 to get it for free

Ali advanced java interview questions and answers

Interview questions:

1. What are the machine learning algorithms you know better, talk about the process and differences of these algorithms

2. What are the five layers of the network architecture and what protocols are in each layer?

3. What is the difference between TCP and UDP, and which protocol should be used if you want to send instant messages

4. In the process of TCP connection establishment and disconnection (three handshake and four wave of hands), how to ensure that the information sent by TCP is correct and that its order is not tampered with

5. How much do you know about the HTTP protocol, what is the difference between HTTP and HTTPS, and how is the security of HTTPS achieved?

6. What kind of engine does mysql usually use?

7. What are the characteristics of database transactions

8. What problems may be caused by transaction concurrency, what are the database isolation levels, what is the default level of mysql, and what problems can be avoided by this default isolation level (reviewed for too long, some forgotten, this problem is actually Incomplete answer)

9. How to judge whether the SQL query operation is slow SQL and how to optimize

10. The difference between process and thread, the method of communication between processes

11. What is a deadlock and what are the methods to deal with it?

12. What are the ways to deal with the critical section in process synchronization

13、spring MVC,spring AOP源码

14. Spring circular references

15. Spring transaction propagation mechanism

16, java nio, bio, aio, operating system underlying nio implementation principle

17. Do you understand java thread programming?

18. What is the data structure of hashmap, how is it implemented, is it thread-safe (no), and what are its thread-safe alternatives?

Two-sided interview questions and reference answers:

What challenges did you encounter in the project?

Reference: Participated in the high-concurrency project of spike.

1. How to deal with the sudden increase of traffic at a certain moment and then a sharp drop?

Reference answer:

  • Peak cut and valley filling

  • Join the message queue on the client and server as a caching mechanism

  • Access layer and each module use cache to increase QPS

2. How to delete expired information/invalid information in redis message queue

Reference answer:

  • Add expiration time limit

  • Different group information uses different queues, and the queue is deleted when the group is full

3. What is the persistence mechanism of redis?

  • Reference answer: RDB and AOF

4. Why do JAVA class loading use parent delegation

  • Example: Object class unique

5. How to achieve synchronization

  • Synchronized keywords

  • Volatile variables

  • Lock object

6. What kinds of JAVA locks are there?

  • Sychronized

  • ReentrantLock

7. The difference between the two locks

  • Synchronized is implemented by JVM

  • ReentrantLock is implemented by JDK

6. Have you understood AQS?

  • AQS (Abstract Queue Synchronizer) queue synchronizer

  • Consists of a Valotaile variable marking the state State, and a CLH (synchronization, FIFO) queue

Specific implementation class:

  • CountdownLatch: wait for multiple threads to complete;

  • CyclicBarrier: synchronization barrier;

  • Semaphore: Control the number of concurrent threads.

7. Scenario: Add a timeout exception to a method

  • Use AspectJ for AOP development

  • Cut method calls into Around

  • Use the Future object to create a thread, and perform timing while calling the method

  • Throw a timeout exception if Future returns the value first

  • Otherwise, call normally

Comment on "Interview" at the end of the article: Add assistant VX: MXW5308 to get it for free

Java development job interview question classification summary (there are related interview answers at the end of the article)

One, Java basics

1. Why the String class is final

2. HashMap source code, implementation principle, and underlying structure.

3. Tell me about several Java collection classes you know: list, set, queue, map implementation classes.

4. Describe the implementation and differences between ArrayList and LinkedList

5. What are the queues in Java and what are the differences.

6. In reflection, the difference between Class.forName and classloader.

7. New features of Java7 and Java8

8. The operation efficiency of the two structures of Java array and linked list, under which conditions (starting from the beginning, starting from the end, starting from the middle), which operations (insertion, search, deletion) are efficient.

9. Investigation and positioning of Java memory leaks: the use of jmap, jstack, etc.

10. string、stringbuilder、stringbuffer区别

11. The difference between hashtable and hashmap

13. The structure of the exception, runtime exception and non-runtime exception, each give an example.

14. Common methods of the String class

16. What are the reference types in Java

17. The difference between abstract class and interface

18. Java basic types and byte size

19. Hashtable, HashMap, ConcurrentHashMap underlying implementation principles and thread safety issues.

20. If you are not allowed to use the tools provided by Java Jdk and you implement a Map yourself, what do you do? After talking for a long time, I talked about the HashMap source code. If I do, I will learn from the principle of HashMap and talk about the implementation of HashMap.

21. What about Hash conflicts? What are the ways to resolve hash conflicts?

22. HashMap conflict is very severe, the worst performance, how would you solve it? From O(n) to log(n).

23. rehash

24. How to rewrite hashCode() and equals() generation algorithms and methods.

二 、 Java IO

1. Talk about the common classes in IO, byte stream, character stream, interface, implementation class, method blocking.

2. Talk about NIO

3. What is the difference between String encoding UTF-8 and GBK?

4. When to use byte stream and when to use character stream?

5. Recursively read the files in the folder, how to implement the code?

Three, Java Web

1. The difference and connection between session and cookie, the life cycle of session, and session management when multiple services are deployed.

2. Some related issues of servlet

3. Webservice related issues

4. The steps of jdbc connection, forname method, how to declare the use of a transaction.

5. Configure the main configuration content of web.xml without framework

6. The difference between jsp and servlet

Four, JVM

1. Java memory model and GC algorithm

2. What has been done in jvm performance tuning

3. Introduce 7 areas in JVM, and then explain the situation that each area may cause memory overflow.

4. Introduce GC and GC Root abnormal references

5. From the classload loading method and loading mechanism, from the data area when the program is running, to the memory allocation, to the String constant pool, to the JVM garbage collection mechanism, algorithm, and hotspot.

6. How to allocate direct memory in jvm, how to allocate new objects not on the heap but on the stack, constant pool analysis.

7. How big is the array in the old JVM

8. How to access arrays in the old age

9. GC algorithm, how to GC permanent generation objects, and how to deal with GC loops.

10. Who will be GC and when?

11. What if I don’t want to be GC

12. What if you want to survive 1 time in the GC

Five, open source framework

1. The difference between hibernate and ibatis

2. Talk about the connection pool of mybatis

3. Which jar packages need to be referenced in the spring framework and the purpose of these jar packages

4. The principle of springMVC

5. The meaning of springMVC annotations

6. The connection and difference between beanFactory and ApplicationContext in spring

7. Several ways of spring injection

8. How does spring manage things

9. springIOC

10. The principle of spring AOP

11. How to use level 1 and level 2 cache in hibernate and the difference principle (understanding of Lazy-Load)

12. Hibernate principle architecture, five core interfaces, three state transitions of Hibernate objects, transaction management.

Six, multi-threaded

1. After Java creates a thread, the difference between calling start() and run() directly

2. Common thread pool modes and usage scenarios of different thread pools

3. What will happen to newFixedThreadPool if the number of threads in this thread pool reaches the maximum? The underlying principle.

4. The synchronization problem of communication between multiple threads. Synchronized locks are objects. 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.

5. Understand the meaning of reentrant locks and the difference between ReentrantLock and synchronized

6. Synchronized data structure, such as the source code understanding of concurrentHashMap and internal implementation principles, why is it synchronized and efficient.

7. Understanding and use of keywords for thread-safe operations such as atomicinteger and Volatile

8. Inter-thread communication, wait and notify

9. The use of timing threads

10. Scenario: In a main thread, a large number of (many, many) child threads are required to execute before the main thread is executed. Consider efficiency in many ways.

11. The difference between process and thread

12. What is thread safety?

13. Several states of thread

14. Concurrent and synchronous interfaces or methods

15. Is HashMap thread safe, and why is it unsafe? ConcurrentHashMap, thread safety, why it is safe. What is the underlying implementation?

16. The use of common classes under the JUC. In-depth investigation of ThreadPool; use of BlockingQueue. (The difference between take and poll, the difference between put and offer); the realization of atomic classes.

17. Briefly introduce the situation of multi-threading, starting from the establishment of a thread. Then how to control the synchronization process, the methods and structures commonly used in multithreading

18. Understanding of volatile

19. There are several ways to achieve multi-threading, how to do multi-thread synchronization, and talk about the commonly used methods in several threads.

Seven, network communication

1. http is stateless communication. What are the HTTP request methods? Can you define new request methods yourself?

2. Socket communication, and handling of long connections, sub-packaging, and abnormal disconnection of connections.

3. The use of socket communication model, AIO and NIO.

4. The use of socket framework netty, and the realization principle of NIO, why is it asynchronous and non-blocking.

5. Synchronous and asynchronous, blocking and non-blocking.

6. OSI seven-layer model, including some basic knowledge of TCP and IP

7. The difference between get post in http

8. Talk about the relationship and difference between http, tcp and udp.

9. Talk about the process of the browser visiting http://www.taobao.com.

10. HTTP protocol, HTTPS protocol, SSL protocol and complete interaction process;

11. TCP congestion, fast return, ip packet discard

12. A process of https processing, symmetric encryption and asymmetric encryption

13. The characteristics and differences of head

14. Talk about the process of the browser visiting http://www.taobao.com.

Eight, the database MySql

1. MySql storage engine is different

2. Single index, joint index, primary key index

3. How does Mysql split tables, and what to do if you want to query by condition after splitting the tables

4. After the table is divided, I want to make multiple tables of one id increase automatically, and the efficiency is realized

5. The configuration and principle of MySql's master-slave real-time backup synchronization (read the binlog of the master library from the library), read and write separation.

6. Write SQL statements and SQL optimization

7. Index data structure, B+ tree

8. The four characteristics of transactions, and their respective characteristics (atomic, isolation), etc., how does the project solve these problems?

9. Database locks: row locks, table locks; optimistic locks, pessimistic locks

10. Several granularities of database transactions

11. The difference between relational and non-relational databases

Nine, design patterns

1. Singleton mode: full man, hungry man. And the lazy loading in the hungry man, double check.

2. Factory mode, decorator mode, observer mode.

3. The advantages of the factory method pattern (low coupling, high cohesion, open and closed principles)

10. Algorithm

1. Use a random algorithm to generate a number, requiring all the numbers between 1-1000W to be generated.

2. The merge sort of two ordered arrays

3. Reverse order of an array

4. Calculate the positive square root of a positive integer

5. To put it bluntly, those common search and sorting algorithms and their respective time complexity.

6. Binary tree traversal algorithm

7. DFS, BFS algorithm

9. Basic understanding and general implementation of more important data structures, such as linked lists, queues, and stacks.

10. Sorting algorithm and spatio-temporal complexity (why is fast sorting unstable and why your project is still used)

11. Inverse Polish Calculator

12. Hoffman coding

13. Find trees and red-black trees

11. Concurrency and performance tuning

1. There are 5k requests per second to query the written test questions of the mobile phone number. How to design the algorithm? No matter how many requests, such as 5w, how to design the entire system?

2. In the case of high concurrency, how does our system support a large number of requests?

3. How the cluster synchronizes session state

4. Principles of Load Balancing

5. If there is a particularly large amount of visits to the database, how to optimize (DB design, DBIO, SQL optimization, Java optimization)

6. If there is a large area of ​​concurrency, how to solve the problem of slow server response without increasing the server."

7. If your project has a performance bottleneck, what do you think it might be and how to solve the problem.

8. How to find the location that caused the performance bottleneck, and which location is the performance bottleneck.

9. Have you used a caching mechanism in your project? There is no use user non-local cache

12. Other

The above is the interview experience of some well-known big companies and the high-frequency interview test sites. The editor shares the summary of the high-frequency interview questions of the Java interview (including Java collection, JVM, concurrency and multithreading, Spring, MyBaits, microservices, Dubbo) , Kakfa, middleware, Redis, database, design patterns, Zookeeper, distributed, etc.), organized and shared with everyone for free.

How to get answers to high-frequency interview questions from major Java companies: follow the editor, comment "Interview" at the end of the article: add assistant VX: MXW5308 to get it for free.

How to get answers to high-frequency interview questions from major Java companies: follow the editor, comment "Interview" at the end of the article: add assistant VX: MXW5308 to get it for free.

Guess you like

Origin blog.csdn.net/weixin_45132238/article/details/109099788