You have a public class called myclass with the main method defined as follows
public static void main(String parm[]){
System.out.println(parm[0]);
}
If you attempt to compile the class and run the program as follows
java myclass hello
What will happen?
1) Compile time error, main is not correctly defined
2) Run time error, main is not correctly defined
3) Compilation and output of java
4) Compilation and output of hello
Answer :
4) Compilation and output of hello
This type of question is particularly calculated to catch out C/C++ programmers who might expect parameter zero to be the name of the compiler.
No comments:
Post a Comment