59.1k views
4 votes
What extension do Java source code files have

1 Answer

6 votes

Final answer:

Java source code files have a ".java" extension. These files contain the code written by the programmer and need to be compiled to ".class" files before being executed by the Java Virtual Machine.

Step-by-step explanation:

The Java source code files have an extension of ".java". When a programmer writes a Java program, it is saved as a plain text file with this extension. This file then needs to be compiled into bytecode, which has a ".class" extension, before the Java Virtual Machine (JVM) can execute it.

For example, if you write a Java program called MainProgram, you would save it as MainProgram.java. After compiling this file using the javac command, you would get a MainProgram.class file, which contains the bytecode.

User Agus Sanjaya
by
7.7k points