What is the result of the command
javac test.java
if file test.java contains:

// test.java
/* comments */
Explanation
There is a requirement for public classes - they should be placed in a file with a name that matches the name of the class. But it is not required to have a class with the same name in a file. Any non-public classes or comments (as in this question) can be n the .java file. The file may be even empty - and, nevertheless, the compiler will process it correctly.

@nastya I think it's a typo; it should be "in" not "n".

2023 Jun 13, 5:27:30 PM

Any non-public classes or comments (as in this question) can be n the .java file. ??? What does 'n' mean?

2023 Apr 25, 4:04:03 PM

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes