What should the file name match in a Java program?

Question image

Understand the Problem

The question is asking what the file name for a Java program should correspond to, specifically whether it should match the package name, import statement, class name, or method name.

Answer

Class name

The file name should match the class name if there is a public class.

Answer for screen readers

The file name should match the class name if there is a public class.

More Information

In Java, if you have a public class in your file, the file name must match this class name exactly. This is necessary for proper compilation and execution.

Tips

Not matching the file and class names when a public class is present will result in a compilation error.

Thank you for voting!
Use Quizgecko on...
Browser
Browser