Junior — Middle
What do we get in the form of a binary file after compiling a Java program?
sobes.tech AI
Answer from AI
After compiling a Java program, you get a .class file that contains bytecode — an intermediate representation of the program. This bytecode is not machine code for a specific processor but is intended to be executed on the Java Virtual Machine (JVM).
The JVM interprets or compiles the bytecode into machine code at runtime (JIT compilation), which ensures the portability of Java programs across different platforms.
Example:
// HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
After compilation with the command javac HelloWorld.java, a HelloWorld.class file with bytecode will appear.