The file name extension of a Java source program is .java.

Quick Scoop

When you write a Java program, you save the code in a plain text file whose name ends with .java. For example, a simple Hello World program might be stored in a file named HelloWorld.java.

Key points

  • Java source code files use the .java extension (e.g., MyProgram.java).
  • After compilation, Java produces bytecode files with the .class extension (e.g., MyProgram.class).
  • The .java file is what you edit in an IDE or text editor; the .class file is what the Java Virtual Machine (JVM) executes.

Tiny example

  • You write code in Student.java → this is the Java source program.
  • You compile it with javac Student.java → this generates Student.class.
  • You run java Student → the JVM runs the .class bytecode.

So, if a multiple-choice or exam question asks:
“What is the file name extension of a Java source program?”
The correct answer is: .java.

TL;DR: The file name extension of a Java source program is .java.

Information gathered from public forums or data available on the internet and portrayed here.