Hi, all: Q:In order for a source code file, containing the public class Test, to successsfully compile, which of the following must be true? Here is a option : (a)It must declared a public class name Test. As I known, a file with a class with default modifier can also compile and run successfully. Choose (a) or not? In my opinion, I will choose it even if the fact above exists. Thanks. Roger
The method main must be declared public, static, and void. It must accept a single argument that is an array of strings.
I realize that some compilers will execute even if the main method doesn't include the keyword public but, according to the JLS, it must be public. Therefore, as far as the exam is concerned (because the exam is based on the JLS, not every Java compiler on the market), the answer is that the main method MUST be public. I hope that helps, Corey