answersLogoWhite

0


Best Answer

not exactly..... only If your class is public then the java program name should be the public class name with extension Sample.java >> public class Sample { public static void main(String[] args) { ..... } } NonPublicClass.java class SomeOtherName { ......... }

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

It must match only when marking a class/interface/enum as public. You may add other classes/interfaces/enums in the file, but they cannot be public.

If none of them ar marked as public, then the filename may be any valid java identifier followed by the extension "java"

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Yes. The name of the file should be the same as the public class name in the file.

ex:

public class Test {

.....

....

...

..

.

}

This file must be saved as Test.java

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

False.But if you define a class as public class,this class must be written in a java program file that the file's name match the class's name.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

True.

The below code must be present inside a file called "Test.java"

public class Test {

...

...

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

true. Else, it would not compile.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: The name of a Java program file must match the name of the class with the extension java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

The name of a Java program file must match the name of the class with the extension java A True B False?

True


Java program file must match the name of class with extension true or false?

The name of the .java file should exactly match with the name of the public class in the file. Ex: public class Test { ..... } this file should be saved as Test.java


Extension file for Java?

Java source files have the .java extension, compiled Java class files have the .class extension.


Where java program started?

If it is already compiled, you can start your Java program from the command line. Just type java myclass replacing "myclass" with the program you want to start - a program with the ".class" extension, for example, myclass.class.


When java uses compiler?

What i know is java we will use compiler when it want to get class file(file with .class extension) from java file(file with .java extension).


Is java interpreter or compiler?

Java has both a compiled and an interpreted stage.1) The programmer writes his source codes (.java extension); a compiler will compile this to bytecode (.class extension).2) When the end-user runs the .class program, the JVM (Java Virtual Machine) will interpret this.


What JDK command is used to run a java application in byteCodeclass?

To run a Java program, you use the following form: java ClassFileName ClassFileName is the name of the .class file that you wish to execute. However, you do not type the .class extension.


It is not an error not to end a Java file name with the java extension?

If you want to compile a java program the name of that source code must end with extension .java


What is the difference between exe and class files?

in .exe file it contains machine understandable code. but in .class file it contain only byte code which is not understadable by the microprocessor it will understud by the jvm only . we con't execute .class file without jvm . but we can execute .exe file without c-compiler .


What is the extension of a java byte code file?

.class is the extension of a java byte code file.


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


What is the file extension of an applet?

An applet is a Java application, this saves files in a .class extension