41: If I do not provide any arguments on the command line, then the String array of Main method will be empty of null?
A: It is empty. But not null.
42: How can one prove that the array is not null but empty?
A: Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.
43: What environment variables do I need to set on my machine in order to be able to run Java programs?
A: CLASSPATH and PATH are the two variables.
44: Can an application have multiple classes having main method?
A: Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.
45: Can I have multiple main methods in the same class?
A: No the program fails to compile. The compiler says that the main method is already defined in the class.
Friday, May 2, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment