Files containing Java code must end with what extension?

When saving a Java source file, save it with .java extension.

How to name the whole file?

By convention, files are named after the Java class, that is defined in the file.

So, if your class looks something like this:

public class Person {


Then the file should be named: