1.

Can the main method be Overloaded?

Answer»

Yes, It is possible to overload the main method. We can CREATE as many overloaded main methods we want. However, JVM has a predefined calling method that JVM will only call the main method with the definition of - 

PUBLIC static void main(string[] ARGS)

Consider the below code snippets: 

class Main { public static void main(String args[]) { System.out.println(" Main Method"); } public static void main(INT[] args){ System.out.println("Overloaded Integer ARRAY Main Method"); } public static void main(char[] args){ System.out.println("Overloaded Character array Main Method"); } public static int main(double[] args){ System.out.println("Overloaded Double array Main Method"); } public static void main(float args){ System.out.println("Overloaded float Main Method"); }}


Discussion

No Comment Found