Java interview frequently asked basic knowledge points (beginner, intermediate, advanced development/architecture)

Basic Java development interview knowledge points and topics

Java development interview questions

  1. The sizes of the nine basic data types, and their encapsulation classes.
  2. Can Switch use string as parameter? After jdk7
  3. The difference between equals and ==: To compare whether two primitive types of data or two reference variables are equal, you can only use the operator
  4. What public methods does Object have?
    clone
    equals
    hashCode
    getClass
    wait
    notify
    notifyAll
    toString
  5. Four kinds of references in Java, strong and weak, and the scenarios used.
  6. The role of Hashcode.
  7. The difference between ArrayList, LinkedList, and Vector.
  8. The difference between String, StringBuffer and StringBuilder.
  9. Features and usage of Map, Set, List, Queue, and Stack.
  10. The difference between HashMap and HashTable.
  11. The difference between HashMap and ConcurrentHashMap, the underlying source code of HashMap.
  12. The difference between TreeMap, HashMap, and LindedHashMap.
  13. Collection package structure, the difference from Collections.
  14. try catch finally, if there is return in try, is finally still executed?
  15. Excption and Error packet structure. What situations have you encountered in OOM and what situations have you encountered in SOF?
  16. Three characteristics and meanings of Java object-oriented.
  17. The meaning of Override and Overload is different.
  18. The difference between Interface and abstract class.
  19. The difference between static class and non static class.
  20. The realization principle of java polymorphism.
  21. There are two ways to implement multithreading: Thread and Runable.
  22. Thread synchronization methods: synchronized, lock, reentrantLock, etc.
  23. Lock level: method lock, object lock, class lock.
  24. Write a producer-consumer pattern.
  25. The design concept and function of ThreadLocal.
  26. ThreadPool usage and advantages.
  27. Other stuff in the Concurrent package: ArrayBlockingQueue, CountDownLatch, etc.
  28. The difference between wait() and sleep().
  29. Foreach and normal for loop efficiency comparison.
  30. Java IO given NIO.
  31. Reflection works on principle.
  32. Common features of generics, whether List can be converted to List.
  33. Principles and characteristics of several ways to parse XML: DOM, SAX, PULL.
  34. Java1.7 and 1.8 new features.
  35. Design Patterns: Singleton, Factory, Adapter, Chain of Responsibility, Observer, etc.
  36. Use of JNI.

JVM

  1. The memory model and partitions need to be detailed into what to put in each area.
  2. Partitions in the heap: Eden, survival from to, old age, their own characteristics.
  3. Object creation method, object memory allocation, object access positioning.
  4. There are two judgment methods for GC: reference counting and reference chain.
  5. The three collection methods of GC: the principles and characteristics of mark clearing, mark sorting, and copying algorithms, where are they used, and what ideas do you have if you want to optimize the collection method?
  6. What are the GC collectors? Features of the CMS collector and the G1 collector.
  7. When do Minor GC and Full GC happen?
  8. Several commonly used memory debugging tools: jmap, jstack, jconsole.
  9. The five processes of class loading: loading, verification, preparation, parsing, initialization.
  10. Parent delegation model: Bootstrap ClassLoader, Extension ClassLoader, ApplicationClassLoader.
  11. Dispatch: static dispatch and dynamic dispatch.

TCP

  1. What are the structures and functions of each layer of OSI and TCP/IP?
  2. The difference between TCP and UDP.
  3. TCP message structure.
  4. TCP's three-way handshake and four-way wave process, the name and meaning of each state, and the role of TIMEWAIT.
  5. TCP congestion control.
  6. TCP sliding window and fallback N-pin protocol.
  7. Http message structure.
  8. Http status code meaning.
  9. Several types of Http request.
  10. The difference between Http1.1 and Http1.0
  11. How Http handles long connections.
  12. The role of cookies and sessions is based on the principle.
  13. What is the whole process of visiting a web page on a computer: DNS, HTTP, TCP, OSPF, IP, ARP.
  14. Using socket communication in C/S mode, several key functions.
    1. The whole process of Ping. What is an ICMP message.

Data Structures and Algorithms

  1. Linked lists and arrays.
  2. Queue and stack, pop and push.
  3. Deletion, insertion, and reversal of linked lists.
  4. String manipulation.
  5. The hash function of the Hash table, what are the conflict resolution methods.
  6. Various sorting: bubbling, selection, insertion, hill, merge, quicksort, heap row, bucket row, the principle of cardinality, average time complexity, worst time complexity, space complexity, stability.
  7. The partition function of quicksort and the merge function of merge.
  8. Improvements to bubbling and quicksort.
  9. Binary search, and variant binary search.
  10. Binary tree, B+ tree, AVL tree, red-black tree, Huffman tree.
  11. The front, middle and subsequent traversal of binary tree: recursive and non-recursive writing, level-order traversal algorithm.
  12. Graph BFS and DFS algorithms, minimum spanning tree prim algorithm and shortest path Dijkstra algorithm.
  13. KMP algorithm.
  14. permutation problem.
  15. Dynamic programming, greedy algorithms, divide and conquer algorithms. (usually not asked)
  16. Big data processing: similar to 1 billion pieces of data to find the largest 1000 numbers

JAVA basic concepts

1. Is String the most basic data type?

Answer: No. There are only 8 basic data types in Java: byte, short, int, long, float, double, char, boolean; except for primitive types, the rest are reference types. Its in-memory references include stack references and heap references.
2. Explain the usage of stack, heap and method area in memory

Answer: Usually we define a variable of a basic data type, a reference to an object, and the on-site preservation of function calls all use the stack space in the JVM; while the objects created through the new keyword and the constructor are placed in the heap space, The heap is the main area managed by the garbage collector. Since the current garbage collectors all use the generational collection algorithm, the heap space can also be subdivided into the new generation and the old generation. For From Survivor and To Survivor), Tenured; the method area and the heap are memory areas shared by each thread, which are used to store data such as class information, constants, static variables, and code compiled by the JIT compiler that have been loaded by the JVM.
3. Whether the constructor (constructor) can be overridden (override)

Answer: Constructors cannot be inherited and therefore cannot be overridden, but they can be overloaded.
4. The difference between Overload and Override. Can overloaded methods be distinguished by their return type?

Answer: Method overloading and rewriting are both ways to achieve polymorphism. The difference is that the former implements compile-time polymorphism, while the latter implements run-time polymorphism. Overloading occurs in a class. If a method with the same name has a different parameter list (different parameter types, different number of parameters, or both), it is considered overloaded; overriding occurs between the subclass and the superclass, Overriding requires that the overridden method of the subclass has the same return type as the overridden method of the parent class, is more accessible than the overridden method of the parent class, and cannot declare more exceptions than the overridden method of the parent class (Richard Code). change the principle). Overloading has no special requirements on the return type.
5. What are the similarities and differences between an abstract class and an interface?

Answer: Neither abstract classes nor interfaces can be instantiated, but references to abstract classes and interface types can be defined. If a class inherits an abstract class or implements an interface, it needs to implement all the abstract methods in it, otherwise the class still needs to be declared as an abstract class. Interfaces are more abstract than abstract classes, because abstract classes can define constructors, abstract methods and concrete methods, while interfaces cannot define constructors and all the methods are abstract methods. Members in abstract classes can be private, default, protected, and public, while members in interfaces are all public. Member variables can be defined in abstract classes, while those defined in interfaces are actually constants. A class with abstract methods must be declared abstract, and abstract classes do not necessarily have abstract methods.
6. What is the difference between a synchronized method and a synchronized code block

In the Java language, each object has a lock. Threads can use the synchronized keyword to acquire locks on objects. The synchronized keyword can be used at the method level (coarse-grained locking) or at the block level (fine-grained locking).
The members of the class default to default when they are not modified with write access. By default, it is equivalent to public (public) for other classes in the same package, and equivalent to private (private) for other classes not in the same package. Protected (protected) is equivalent to public to subclasses, and equivalent to private to classes that are not in the same package and have no parent-child relationship. In Java, the modifiers of external classes can only be public or default, and the modifiers of class members (including inner classes) can be any of the above four.

System design and deployment

1. Database design principles, popularly understand the three paradigms

A common understanding of the three paradigms is of great benefit to database design. In database design, in order to better apply the three paradigms, it is necessary to understand the
  three paradigms (popular understanding is a sufficient understanding, not the most scientific and accurate understanding):
  The first paradigm: 1NF is the attribute The atomicity constraint requires that the attribute is atomic and cannot be decomposed;
  the second normal form: 2NF is the unique constraint on the record, which requires the record to have a unique identity, that is, the uniqueness of the entity;
  the third normal form: 3NF is redundant to the field The constraint that no field can be derived from other fields, it requires that fields have no redundancy.
  No redundant database design can do it. However, a database without redundancy is not necessarily the best database. Sometimes, in order to improve operational efficiency, it is necessary to
  lower paradigm standard and properly retain redundant data. The specific approach is: follow the third paradigm in conceptual data model design, and put the work of lowering paradigm standards into consideration in physical
  data model design. Decreasing the paradigm is adding fields, allowing for redundancy.
2. Mainly understand the projects the other party participates in and the roles they play in the projects.

If it is a development role, you need to focus on asking the modules it develops, what functions it has implemented, what framework or technology it uses, and whether it has encountered any unforgettable pits.
If it is an architecture and design role, you need to focus on understanding the functional architecture, deployment architecture, runtime architecture, and data flow diagram of the participating modules. You can also ask about system availability, data consistency, performance, etc.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324777264&siteId=291194637