This article "The First Collection of Java Interview Questions in Autumn" is full of dry goods and painstaking efforts! Recommended collection

BAT frequently asked Java basics 39 common interview questions

This can be regarded as 39 basic questions that every major company will ask in an interview. Don't underestimate these 39 questions! Some may not answer.

 

  • 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 to 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. Does HashMap still have 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. Three characteristics and meanings of object-oriented Java (OOP)
  • 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. Commonly used 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

Java Interview Questions for Job-hopping

 The following interview questions can only be understood by programmers with several years of experience, so if you don’t understand, please check yourself and you need to improve.

 

 Java interview questions for experienced programmers

  • What is Busy spin? Why should we use it?
  • How to get a thread dump file in Java?
  • Is Swing thread safe?
  • What are thread local variables?
  • The difference between sleep method and wait method in Java?
  • What is an immutable object? How to create an immutable object in Java?
  • Can we create an immutable object that contains mutable objects?
  • What data type should be used to represent prices in Java?
  • How to convert byte to String?
  • How to convert bytes to long type in Java?
  • Can we cast int to a variable of type byte? If the value is greater than the byte type range, what will happen?
  • Which class contains the clone method? Is it Cloneable or Object?
  • Are ++ operators thread-safe in Java?
  • Not a thread-safe operation. It involves multiple instructions, such as reading variable values, increasing,
  • The difference between a = a + b and a += b
  • Can I assign a double value to a variable of type long without casting?
  • 3*0.1 == 0.3 What will be returned? true or false?
  • Which of int and Integer will take up more memory?
  • Why is String in Java immutable (Immutable)?
  • Can we use String in Switch?
  • What is the constructor chain in Java?
  • Explain Java heap space and GC?
  • Can you guarantee GC execution?
  • How to get the memory used by the Java program? What percentage of the heap is used?
  • What is the difference between heap and stack in Java?

JVM bottom layer and GC (Garbage Collection) interview questions

  • In 64-bit JVM, the length of int is the majority?
  • What is the difference between Serial and Parallel GC?
  • For 32-bit and 64-bit JVMs, the length of int type variables is the majority?
  • What is the difference between WeakReference and SoftReference in Java?
  • How does WeakHashMap work?
  • What does the JVM option -XX:+UseCompressedOops do? Why make
  • How to judge whether the JVM is 32-bit or 64-bit through a Java program?
  • What is the maximum heap memory of 32-bit JVM and 64-bit JVM?
  • What is the difference between JRE, JDK, JVM and JIT?

Java development job interview questions classification summary 

 

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 Java reference types
  • 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 serious, 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 mode, 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, 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, multithreading

  • 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. NewFixedThreadPool, this kind of thread pool, what will happen if the number of threads 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. Synchronous data structure, such as the source code understanding of concurrentHashMap and internal implementation principles, why is it synchronous 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 not safe? 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 to split tables in Mysql, and what to do if you want to query by conditions 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, it is the 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 is a 5k request 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

 

 Due to space reasons; the answers cannot be uploaded together. Those who need interview materials and article answers can "private me and get them for free"

Guess you like

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