Is there is any error if you have multiple main methods in
the same class?

Answer Posted / srikanth

No, there is no error if we have multiple main methods
in the same class.
because, while compiling we only specify one main method
name so, the JVM compiles it by taking the main method which
is specified by us while compiling.

Is This Answer Correct ?    3 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between this() and super() in java ?

606


What causes memory leaks in java?

478


What is entry set in java?

521


Explain illegalmonitorstateexception and when it will be thrown?

602


What is append in java?

617






What is the use of static class?

536


Discuss about garbage collector in Java.

634


Explain about public and private access specifiers?

526


Why do we declare a class static?

533


What is the purpose of using break in each case of switch statement?

559


Why do we use string?

569


Name some classes present in java.util.regex package.

598


What is the benefit of lambda expressions?

484


What is double word?

525


How the interruptible method gets implemented?

548