Learn AP Comp Sci

Problem of the Day

Monday, December 22, 2025


Problem:

Java code is written in text-based source files using a text editor or an integrated development environment, and then compiled into bytecode that can be run on the computer. What instruction should be given at the command-line (in a Terminal) to run a HelloWorld.class bytecode file?

  1. javac HelloWorld.java
  2. javac HelloWorld
  3. java HelloWorld.java
  4. java HelloWorld
  5. java HelloWorld.class

Show solution:

The correct answer is d. The java command invokes the Java Virtual Machine (JVM) which executes the HelloWorld.class file, although the extension shouldn't be included when issuing that command.