Java SE 8 Programmer I — Question 146
Which statement is true about the main() method?
Answer options
- A. It is invoked by JRE
- B. It is a final method
- C. It returns true if it is executed successfully at run time
- D. It must be defined within a public class
Correct answer: A
Explanation
The correct answer is A because the main() method is indeed invoked by the Java Runtime Environment (JRE) to start the execution of a Java program. Option B is incorrect as the main() method is not required to be final. Option C is false because the main() method does not return a boolean value; it returns void. Option D is misleading, as while the main() method must be in a public class for it to be accessible when the program starts, it can also be in a non-public class if the class is accessed differently.