1.

What will be the output in below code?

Answer» PUBLIC class Demo{ public static void main(STRING[] arr){ System.out.println(“Main1”); } public static void main(String arr){ System.out.println(“Main2”); } }

Output:

Main1

Reason:
Here the main() method is overloaded. But JVM only understands the main method which has a String[] ARGUMENT in its definition. Hence Main1 is PRINTED and the overloaded main method is IGNORED



Discussion

No Comment Found