I recently received a
test question (which I missed), that asked if "an empty file is a valid source file". It is. While it will compile successfully, it won't produce a matching class file.
I missed this question, because I thought that every *.java file had to have a matching classname (with the exception of inner classes, where there is a $ sign) contained within it. Apparently this is not true. Because there is a subsequent question, which asks if "A
Java file without any class or interface definitions can also be compiled" and its answer was also true. I am assuming that this means that a matching class file would be produced.
My personal definition of compiled means that a class name is produced, and not that the prompt comes back cleanly. I don't know if this is the general definition or not.
So my question is, what would this file contain?? I tried creating files with only import and package statements, but that didn't produce a class file.
I don't think that it is possible to create a class file without a class or interface definition contained within the originating source file.