Given the code in a file Traveler.java:



And the commands:

javac Traveler.java
java Traveler Java Duke

What is the result?

A.

Happy Journey! Duke

B.

Happy Journey! Java

C. An exception is thrown at runtime
D. The program fails to execute due to a runtime error

題解

程式第11行,呼叫Tours類別的main靜態方法,並把main的args參數作為引數繼續傳遞過去。在CLI介面下傳入給Java程式的參數索引值是從0開始的,題目的要傳給Traveler類別的參數是「Java Duke」,因此args[0]="Java",args[1]="Duke"。