Cho chương trình tên message.class: public static void main(String[] args) { if (args.equals(“-g”)) System.out.print(“Goodbye, “); for (int i = 1; i < args.length; i++) System.out.print(“ “ + args[i]); } Nếu chương trình chạy với lệnh java message -g cruel world, vậy tham số args có giá trị là gì?
>
Trả lời:
Đáp án đúng: D
The `args` parameter in Java's `main` method receives command-line arguments as a string array. In the given command `java message -g cruel world`, `args[0]` would be "-g", `args[1]` would be "cruel", and `args[2]` would be "world". The `args.equals("-g")` comparison in the code checks for object equality which will always return false and the loop starts from index 1 printing out "cruel world".