A Java class named Printer must be saved using which source file name?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Prepare for the Arizona State University CSE110 Exam 1. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for success!

In Java, the naming convention for source files requires that a class name matches the filename exactly, with the exception of the file extension. Since the class is named "Printer," the correct file name must be "Printer.java." This indicates that the file contains Java source code that can be compiled to produce bytecode. The ".java" extension is specifically used for files that contain Java source code.

The other options provided do not align with Java's conventions for source code. For instance, "Printer.class" refers to the compiled bytecode file that results from compiling the "Printer.java" source file, not a source file itself. Similarly, "Printer.txt" and "Printer.doc" suggest file formats that are not suited for Java source code, as they imply plain text or document formats rather than Java code. Therefore, using "Printer.java" is the only appropriate choice for saving a Java class named Printer.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy