JavaBasic1. Where Java is different from other languages
A: The biggest feature of Java is its platform independence, the Java compiler compiled Java source code into bytecode and then the JVM is responsible for interpreting execution, for the world's most popular platform has its corresponding Jvm,java bytecode can be run on a platform with JVM support, Other languages often need to compile specific libraries for specific platforms.
2. Why is Java written once, running everywhere
A: You can write Java code on Windows and compile it in Windows. Classes and jar files obtained from Windows can be run in a UNIX environment, truly cross-platform. All of this portability is behind Java bytecode. The bytecode generated by the Java compiler can be interpreted by any JVM. As a result, it's easier to write Java programs that can run on almost any platform. The Java compiler is responsible for compiling, and the JVM is responsible for interpreting execution.
3. How the class loader works in Java
A: In Java, the class loader is used to load class files, which can be obtained from a specified physical location, such as a file system, or a network location.
There are three main ways of doing this:
- Bootstrap ClassLoader This is the first class loader that loads classes from the Rt.jar file.
- Extension ClassLoader: (Extension class loader), which loads class files from Jre/lib/ext.
- Application ClassLoader: It relies on the classpath to find the location of the class file, and if you specify a jar in the Classpath, the class load will load them.
4. The word main is used in the main method do you think it is a keyword?
A: No, it is a method name, we can take another method of the same name in a class, it is not a keyword.
Java Face question 02