This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javaprepare.com - Questions - Language Fundamentals

 
Thiru Narayanan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question No. 17 of the Subject goes like this:
Which of the following are legal Java programs. Select all the correct answer.
D) package pkg;
import java.awt.*;
Option 'D' is also given as correct. If only these two lines are available in the source file in what name the file is to be saved? And how can it be compiled and run?
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thiru,
An empty file is a valid Java program. The JVM only stipulates that the top-level class inside the file have the same name as the file itself (capitalization also). Since you have no class inside the file, the JVM performs no check; hence, no complaints!
Regards,
Manfred
 
Thiru Narayanan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
But my question was in what name the empty file is to be stored? I was thinking all along that you have to give a name to save a file.
THIRU
 
Amit Madan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
you can give any name to it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic