I am fairly new to Java, and whenever we have written programs in school, we put each class in a separate java file, but I do not remember why this was (if there was even a reason). Right now I am going back over my notes and trying to "understand" how it all works.
Is this necessary to do, and why? Moreover, is there a distinction about where the files should be stored—e.g. in the same directory?
E.g. if we have a class 'Vehicle' and a class 'Car' extending 'Vehicle', do we need to save 'Vehicle' and 'Car' in java files 'Vehicle.java' and 'Car.java', respectively, or could both classes be saved in (say) 'Test.java'?
Duplication disclaimer: my question differs from this one, as mine asks whether it is possible to put multiple classes in one .java file; I am specifically interested in the explanation, i.e. why it is/not possible. I am not interested in what the method is called (the linked question just says 'it is necessary, now what is it called?'): my question is more basic than this.