You can write any number of classes in a single Java program. Suppose I've written three classes A, B and C in the same java file. Then any one of these classes will have the main method. Suppose class C has the main method inside it. Then the name of that program must be C.java and preferably it has to be public.
I know this has been marked as solved, but thought i'd chime in.
Completely agree with Mr. jwenting. The only effect is on the readability of code and code maintainability. The purpose of including multiple classes (non-public top-level, nested and inner classes) in one source file is to bundle related support functionality together. The public class must be implemented in a file with the same name as the class. A single .java file can contains one public and optionally some non-public top level classes, public nested and inner classes. This is useful if the classes are only used internally by the public class.