The answer to the following question is d. Run-time error. Can someone please explain this to me? I think that the last array element that is accessed is 5 which is 'F'. Doesn't the "i++" get evaluated before the comparison so that the output would be BCDEF? Don't we break out of the while loop before an access of arg[6] is attempted?
Thank you! These exams are very good. Very hard. They seem much harder than the JQ+ exams to me and the explanations are excellent.
Question 27
class JMM101 {
public static void main(
String[] args) {
int i = 0;
while (i++ < args.length) {
System.out.print(args[i]);
}}}
java JMM101 A B C D E F
What is the result of attempting to compile and run the program using the specified command line?
a. Prints: JMM101ABCDEF
b. Prints: ABCDEF
c. Compile-time error
d. Run-time error
e. None of the above