Javatpoint Logo

can we use multiple main method in java?

By: yogesh*** On: Thu May 16 00:04:26 EDT 2013     Question Reputation15 Answer Reputation0 Quiz Belt Series Points0  15Blank User
Can we use more than two main method in java langUp3Down

 
Yes. 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 amongst the multiple classes having main method.Image Created5Down

By: [email protected] On: Thu May 16 02:07:03 EDT 2013 Question Reputation14 Answer Reputation44 Belt Series Points2 60User Image
Are You Satisfied :4Yes5No
 
We can overload main method but we can not override it.
So , we can have many main methods in a class.
Image Created3Down

By: [email protected] On: Thu May 16 04:59:13 EDT 2013 Question Reputation29 Answer Reputation63 Belt Series Points0 92User Image
Are You Satisfied :6Yes1No
 
It is possible in java..

class A
{
public static void main(string args[])
{
}
public static void main(string args[])
{}
public static void main(string args[])
{
}
public static void main(string args[])
{}
}
Image Created0Down

By: [email protected] On: Sat May 18 14:27:19 EDT 2013 Question Reputation15 Answer Reputation0 Belt Series Points0 15User Image
Are You Satisfied :2Yes4No