What will be the result of compiling following code
public class MyClass
{
public static void main(
String args[])
{
System.out.println("In first main()");
}
public static void main(char args[])
{
System.out.println('a');
}
}
(1) Code will not compile and will give "Duplicate main() method declaration" error
(2) Code will compile correctly but will give a runtime exception
(3) Code will compile correctly and will print "In first main()" (without quotes) when run with argument of 'a'.
(4) Code will compile correctly and will print "a" (without quotes) when run with argument of 'a'.
The corrct answer is 3. I don't see how. Can someone please explain?
Can we have more than one main() method?