Java面试题及答案解析
- What is Java's principle of platform independence? Answer: Java is platform-independent because it uses the Java Virtual Machine (JVM) to convert Java code into bytecode, which can be interpreted by the JVM at runtime. This allows Java code to be written once and run on multiple platforms without recompiling. 2. What are the differences between the final, finally and finalize ? Answer: Final is a keyword that is used to restrict the user or programmer from modifying a variable or a class or a method. Finally is a block that is used to place important code such as closing database resources. Finalize is a method that is called before an object is destroyed by the Garbage Collector. This method can be overridden to clean up resourses such as closing database connection. 3. What is the difference between abstract class and an interface? Answer: An abstract class is a class that cannot be created, but can only be inherited. An interface is a blueprint for a class that defines a set of methods and constants without providing the implementation. The key difference is that an interface can be implemented by multiple classes, while an abstract class can only be extended by one class.
下载地址
用户评论