Multiple choice technology programming languages

In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?

  1. It must have a package statement

  2. It must be named Test.java

  3. It must import java.lang

  4. It must declare a public class named Test

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Java requires that public class names match the source file name exactly. If a source file contains a public class named Test, the file must be named Test.java. Package statements and imports are optional - java.lang is imported automatically by default.