public class Arg{
String[] MyArg;
public static void main(String argv[]){
MyArg=argv;
}
public void amethod(){
System.out.println(argv[1]);
}
}
1) Compile time error
2) Compilation and output of "hello"
3) Compilation and output of "there"
4) None of the above
Answer)
1) Compile time error
You will get an error saying something like "Cant make a static reference to a non static variable". Note that the main method is static.
No comments:
Post a Comment