EMC Interview Question
Software Engineer in TestsTeam: RSA
Country: India
Interview Type: Written Test
But what will be the answer if the first function whose argument is string args[] is the third function ??
:) The order of the function doesn't matter. If there is a main function with signature public static void main (String []args) in a public class. No matter where it appears in the lexicographic order in the code. That is the first function to be invoked by the JVM.
Moreover if you see two main functions with this signature then you are in trouble, It must give a compilation error saying duplicate methods.
Here JVM understands only the main method that has String type as its arguments, as the data read from the console is always in character format and the other methods does not have any calls in the main(String args[]).So not possible to execute the remaining methods .the out put is just hello
First of all this class has to be public. Assuming this class is public class A. It will call the first method with arguments String[] and print Hello. The rest two methods will not be executed.
- dharmendra June 02, 2012