top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can an application have multiple classes having main method?

+3 votes
371 views
Can an application have multiple classes having main method?
posted Dec 8, 2013 by Neeraj Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict among the multiple classes having main method.

Another point is that you can have overloading also with the main method which means there can be two main method with the different parameters.

public static void main(String[] args)
public static void main(StringSecond[] args)
answer Dec 9, 2013 by Naveena Garg
...