1. About common packages
Basic package: String Math Integer...
Toolkit: Collection Map Date
Database related: Connection
Input and Output: OutputStream File
2. The difference between JDK, JRE, and JVMA
JDK: is a toolbox for Java development, including jre, and also includes javac tool class (compiler) that compiles java files into class files. In addition, it also includes java native API; including J2SE (standard version), J2EE (enterprise version), and J2ME (for mobile devices)
JRE: It is a java running environment, and all java programs must be run under JRE; including JVM
JVM: Virtual machine, Java runs dependent on virtual machines, and because of virtual machines, it can cross-platform
3. The difference between &&&&
&&It has a short circuit function, that is, the first expression is false, the second expression will no longer be calculated; & Whether the first one is correct or not will be calculated
4. Can a char-type variable store a Chinese character?
The char-type variable is used to store Unicode-encoded characters. The unicode-encoded character set contains Chinese characters, so Chinese characters can be stored in the char line variable. However, char cannot store Chinese characters contained in unicode. Supplement: char type variables account for two bytes
5. The data type accepted by switch by default
byte 、shot、int、char String
6. Java basic data types
byte shot int long float double char boolean
7. Is the String type a basic data type?
It is a final type class, so it cannot be inherited or modified.
8. What is the difference between int and Integer (automatic installation and disassembly)
int is the original type. Integer is a reference type.
9. The difference between String and StringBuffer
The value of String cannot be changed. The value of StringBuffer can be modified
10. Three major features of java object-oriented
Encapsulation, inheritance, polymorphism
11. Static variables, member variables, local variables
Static variables | Member variables | Local variables | |
Belongs to | Belongs to the category | Belongs to the object | Belongs to the method |
Location | Outside the method in class | Outside the method in class | Within the method |
Memory | Static zone | Heap space | Stack space |
cycle | Load with class | Load with the object | Load with the method |
Initial value/call | Default initial value, called by class name | Default initial value, called through object | No initial value, use by method |
① static { ("static code block") }
② { ("Constructing code block"); }
③ public Student() { ("Construction Method"); }
Execution order ① ② ③The results appear after multiple executions①Execute once ② ③Repeat execution
13. The difference between Collection, Collections, List, Set
Both List and Set inherit from Collection, which is the top-level interface of the collection. Collections are collection tool classes. list is an ordered collection interface, ArrayList, LinkedList, and Vector are its implementation classes; Set is an unordered and non-repeat collection interface, and HashSet, LinkedHashSet, and TreeSet are its implementation classes.
14. The difference between ArrayList, LinkedList, Vector
ArrayList Vector: The underlying layer is an array, fast query, slow addition and deletion. ArrayList is efficient and thread-unsafe; Vector is low and thread-safe
LinkedList: The underlying layer is the linked list structure, slow query, fast addition and deletion
15、HashMap、HashTable
HashMap is efficient, thread-safe, and allows keys or values to be empty
HashTable thread-safe, inefficient, does not allow keys or values to be empty
16. The difference between arrays and sets
Arrays can store basic data types or objects with fixed length
The collection can only store objects and can vary in length.
17. Common data structures
Stack, queue, array, linked list, tree
18. The difference between Map interface and Collection interface
Map is double column, Collection is single column
The key value of Map is unique, and the subinterface set of Collection is unique.
The data structure of the Map is valid only for keys. Collection is valid for elements
19. Problems between Integer and int values
integer directly assigns the value. If the number is between -128 and 127, the result is true, otherwise it is false
Two new Integers will not be equal
int and integer (whether new or directly assigned), as long as the values are the same, it will be true
20. The difference between runtime exception and compile time exception
Runtime Exception: RuntimeException class and its subclasses There are no errors during the compilation process, and an error will be reported during the runtime.
Compilation time exception: An error occurred during compilation. Must be resolved to run
21. How to handle exceptions
Try catch solves it directly within the method
throws throws exceptions to the previous level to solve, multiple exceptions can be thrown, and may be thrown.
ps: throw an exception object, it will definitely be thrown.
22. The difference between final, finally, finalize
Final modifier variables are constants, modification methods cannot be rewritten, and modification classes cannot be inherited
Finally try-catch-finally statement code, must be executed
finalize garbage collector method
23. OSI seven-layer model
The first layer: the physical layer,
The second layer: the data link layer,
The third layer: network layer,
Layer 4: Transport layer,
The fifth layer: the conversation layer,
The sixth layer: the presentation layer,
The seventh time: application layer.
24. Packaging concept
Hide the properties and implementation details of the object, providing only public access methods
25. Inheritance concept
Extract the duplicate attributes and methods in the class into a class, and other classes define these attributes in an unordered manner. You only need to inherit this class.
26. Polymorphic concept
Allows objects of different classes to respond to the same message.
27. The difference between Overload and Override
Rewriting and overloading are both manifestations of Java polymorphism. Rewriting is a manifestation of polymorphism between parent and child class, and overloading is a manifestation of polymorphism in a class. When overriding, the parameters, return value, and method names must be the same; when overloading, the parameters, return value can be different, and the method names must be the same.
28. What is the difference between error and exception
error means recovery is not impossible, but it is very difficult, such as memory overflow
Exception means programming problems, which can be solved by modifying the program.
29. The difference between abstract classes and interfaces
There can be abstract methods or no in abstract classes, and the interface must be abstract methods.
Abstract classes can only be inherited by single, while interfaces can be implemented multiple times.
In the abstract class, extend implements the abstract class and implements the interface.
Abstract classes have constructors, but interfaces do not.
There can be a main method in the extraction class, but not in the interface.
30. Array length attribute String length method
31. Describe the principle and mechanism of JVM loading class files?
Class loading in JVM is implemented by ClassLoader and its subclasses. Java ClassLoader is an important Java runtimesystemComponents. It is responsible for finding and loading classes of class files at runtime.
56、Multi-threadedThere are several implementation methods, what are they? There are several implementation methods, what are they?
There are two implementation methods for multithreading, namely inheriting the Thread class and implementing the Runnable interface.
There are two types of synchronization implementation, namely synchronized, wait and notify.