(51CTO official Java development engineer QQ group (27163376), please enter your ID for verification. A collection of Java interview questions, suitable for college students who are about to graduate and want to find an office in development. Basic knowledge: 1. Simple principles and use of exception management mechanisms in C or Java. When the JAVA program violates the semantic rules of JAVA, the JAVA virtual machine will represent the generated error as an exception. Violation of semantic rules includes two situations. One is the built-in semantic detection of the JAVA class library. For example, if the subscript of the array is out of bounds, it will cause IndexOutOfBoundsException; when accessing the null target, it will cause NullPointerException. Another situation is that JAVA allows programmers to extend this semantic detection, programmers can create their own exceptions, and freely choose when to use the throw keyword to cause exceptions. All exceptions are subclasses of java.lang.Thowable. 2. The interface of Java and the virtual class of C are the same and different. Because Java does not support multiple inheritance, and it is possible that a certain class or object needs to use methods or properties in several classes or objects, the existing single inheritance mechanism cannot meet the requirements. Compared with inheritance, interface has higher flexibility because there is no implementation code in interface. When a class implements the interface, the class must implement all the methods and properties in the interface, and the properties in the interface are publicstatic by default, and all methods are public by default. A class can implement multiple interfaces. 3. The advantages and principles of garbage collection. And think about 2 retraction mechanisms. An obvious attribute of Java language is the introduction of garbage collection mechanism, which makes the problem of memory management, which is the most troublesome for C programmers, easily solved. It makes Java programmers no longer need to think about memory management when writing programs. Because of the garbage collection mechanism, objects in Java no longer have the concept of scope of effect, only the reference of the object has scope of effect. Garbage collection can effectively avoid memory leaks and use available memory efficiently. The garbage collector usually runs as a separate primary thread. Under unpredictable conditions, it clears and collects objects in the memory heap that have passed away or have not been used for a long time. Programmers cannot call the garbage collector in real time for a certain The target or all targets are garbage collected. The collection mechanism includes generational imitation garbage collection, marked garbage collection, and incremental garbage collection.
JAVA interview questions collection.doc)