94.8k views
2 votes
If a class contains a main method, that method is executed

automatically when the class is run.
when another method within the class calls it.
when an object is created from the class.
None of the above

User Aldrian
by
5.2k points

1 Answer

2 votes

Answer:

Automatically when the class is run.

Step-by-step explanation:

Whenever we run the class the Java Virtual Machine(JVM) always searches the main function.If the main function is found it will call the main function automatically and will execute the main function automatically because it is static..So from the options given the answer is option A.

User Chakrit
by
5.2k points