top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Can an application have multiple classes having main method?

+3 votes
58 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 Google+ Share Button LinkedIn Share Button Multiple Social 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...