问题:
public class Test {
public static void main(String [] args) {
System.out.println(args.length > 4 &&
args[4].equals(“-d”));
}
}
If the program is invoked using the command line: java Test One Two Three –d
What is the result?()
A . true
B . false
C . Compilation fails.
D . An exception is thrown at runtime.
public class Test {
public static void main(String [] args) {
System.out.println(args.length > 4 &&
args[4].equals(“-d”));
}
}
If the program is invoked using the command line: java Test One Two Three –d
What is the result?()
● 参考解析
The correct answer to this question is D. The args[4] generates a runtime exception error because there are only 4 strings and the expression args[4] prints the 5th String but like it was said earlier, there are only 4 strings.
相关内容
相关标签