102k views
4 votes
If a class contains a main() method, that method is executed Select one: a. when the class is run b. when another method within the class calls it c. when an object is created from the class d. none of the above

1 Answer

0 votes

Answer:

A. When the class is run

Step-by-step explanation:

The main( ) method is part of its class and not part of objects. So, when the class is run, the main method serve as a point of entry during program execution.

The main( ) method in the Java language is similar to the main( ) function in C and C++.

Without main( ) method in a class, the program cannot be executed but object of a class can be created as the main( ) method is where the path of execution are mostly defined.

User Coelhudo
by
7.3k points