Question
Which statement about a valid .java file is true?
- A. It can only contain one class declaration.
- B. It can contain one public class declaration and one public interface definition.
- C. It must define at least one public class.
- D. It may define at most one public class.
D.
Note
A valid .java file may define any number of classes or interfaces.
It can have at most one public class.
It can also not define any public classes.
Option A, B, and C are incorrect.
Option D is the only correct answer.
PreviousNextRelated