Step 1: Understanding the Java compilation process.
In Java programming, a program is first written in a source file that has the extension .java. This source file contains the human-readable Java code written by the programmer.
Before the program can run, the Java compiler must convert this source code into a format that the Java Virtual Machine (JVM) can understand.
Step 2: Role of the Java Compiler.
The Java compiler, known as javac, translates the Java source code into an intermediate form called bytecode. This bytecode is stored in a file that has the extension .class.
This compiled file contains platform-independent instructions that can be executed by the Java Virtual Machine on different operating systems.
Step 3: Evaluation of options.
(A) .class: Correct. This is the bytecode file generated by the Java compiler.
(B) .txt: Incorrect. This extension represents a plain text file.
(C) .obj: Incorrect. This extension is used in some other programming languages such as C or C++.
(D) .exe: Incorrect. This extension is used for executable programs in Windows systems.
Step 4: Conclusion.
Therefore, when a Java program is compiled successfully, the compiler generates a file with the extension .class.
Final Answer: .class