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

Answer Posted / nisha

The compilation error, if you have multiple main
methods in the same class.
Error like :java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: Uncompilable source
code - main(java.lang.String[]) is already defined

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a super method?

530


What is difference between length and length() method in java ?

558


What is an abstract class and what is it’s purpose?

537


What are the java ide's? Explain

523


Is main a function?

512






Can we use both this () and super () in a constructor?

546


Can an interface have a constructor?

511


What is difference between hashset and hashmap in java?

460


Describe what a thread-local variable is in java?

565


What is difference between float and double?

496


How will you load a specific locale?

536


Can final class have constructor?

497


is it possible to instantiate the math class?

524


What do you mean by JVM?

585


What is method and methodology?

608