Which command compiles Java source code?

Prepare for the Computer Programming Test. Study with flashcards and multiple-choice questions, each with detailed hints and explanations. Gear up for success!

Multiple Choice

Which command compiles Java source code?

Explanation:
Compiling Java source code is done with the Java compiler, which translates .java source files into Java bytecode (.class files) that the JVM can run. The command for this is javac. When you run something like javac MyProgram.java, the compiler checks syntax, resolves types, and produces MyProgram.class (and any needed auxiliary class files) in the output directory. You can compile multiple files at once with wildcards, or specify options like -d to choose the output folder. In contrast, the java command runs a program by starting the Java Virtual Machine on a compiled class file; it does not perform compilation. javap is a tool that inspects compiled class files to show their structure, not to compile. compilejava isn’t a standard Java tool provided by the JDK.

Compiling Java source code is done with the Java compiler, which translates .java source files into Java bytecode (.class files) that the JVM can run. The command for this is javac. When you run something like javac MyProgram.java, the compiler checks syntax, resolves types, and produces MyProgram.class (and any needed auxiliary class files) in the output directory. You can compile multiple files at once with wildcards, or specify options like -d to choose the output folder.

In contrast, the java command runs a program by starting the Java Virtual Machine on a compiled class file; it does not perform compilation. javap is a tool that inspects compiled class files to show their structure, not to compile. compilejava isn’t a standard Java tool provided by the JDK.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy