Java面试题合集【送给将毕业的大学生】
51CTO官方Java开发工程师QQ群(27163376),验证请输入您的ID。Java面试题合集,适合于将要毕业的想要往开发方面找办公的大学生。基础知识:1.C++或Java中的异常管理机制的简单原理和使用。当JAVA程序违反了JAVA的语义规则时,JAVA虚拟机就会将生成的错误表示为一个异常。违反语义规则包括2种状况。一种是JAVA类库内置的语义检测。例如数组下标越界,会引起IndexOutOfBoundsException;访问null的目标时会引起NullPointerException。另一种状况即是JAVA许可程序员扩展这种语义检测,程序员可以创建自己的异常,并自由选择在何时用throw关键字引起异常。一切的异常都是java.lang.Thowable的子类。2.Java的接口和C++的虚类的一样和不一样处。因为Java不支持多承继,而有可能某个类或目标要使用分别在几个类或目标里边的方法或属性,现有的单承继机制就不能满足要求。与承继比较,接口有更高的灵活性,因为接口中没有任何实现代码。当一个类实现了接口今后,该类要实现接口里边一切的方法和属性,而且接口里边的属性在默许状况下面都是publicstatic,一切方法默许状况下是public.一个类可以实现多个接口。3.垃圾收回的长处和原理。并思考2种收回机制。Java语言中一个明显的属性即是引入了垃圾收回机制,使c++程序员最头疼的内存管理的问题方便的解决,它使得Java程序员在编写程序的时候不再需求思考内存管理。因为有个垃圾收回机制,Java中的目标不再有效果域的概念,只要目标的引证才有效果域。垃圾收回可以有效的避免内存泄露,有效的使用可以使用的内存。垃圾收回器通常是作为一个独自的初级其他线程运行,不行预知的状况下对内存堆中现已逝世的或许长期没有使用的目标进行清楚和收回,程序员不能实时的调用垃圾收回器对某个目标或一切目标进行垃圾收回。收回机制有分代仿制垃圾收回和标记垃圾收回,增量垃圾收回。JAVA面试题调集.doc
(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)
页:
[1]