Here is the answer.
As per the Java convention and guide lines every class declared as public must be defined individually in a single file. If we have two public classes then we need to have to separate files for them. We can not put them in a single Java file. If you try to put also, you will see syntax error.