A source file can have any number of top-level classes, but at most one of them can be public. If there is a public class, its name must match the name of the file.
Any class, public or not, can have a method with the signature
public static void main (
String[] args)
and if you feed such a class to the
java interpreter, that method will execute.