The Correct answer of the ques “what is the correct extension of java code file” is option number (B) .java
When you compile your .java files intermediate code file is generated which is having .class extension.
.txt is a general text file extension, not specific to Java code
.js is the extension for JavaScript files, which is a different programming language.