Home > DeveloperSection > Interviews > Can we overload main() method?

Posted on    March-30-2015 2:17 AM

 Java Java 
 1 Answer(s)
  593  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Posted on    March-30-2015 2:38 AM

Yes, by method overloading. We can have any number of main methods in a class by method overloading. Here is a example:

class Overloading1{  
  public static void main(int a){  
  public static void main(String args[]){  
  System.out.println("main() method invoked");  
Output : 10

Don't want to miss updates? Please click the below button!

Follow MindStick