• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Valid Java file

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic