1Z0-803 · Question #207
Given: And the commands: Javac Jump.java Java Jump crazy elephant is always What is the result?
The correct answer is D. Elephant is always jumping. The Java program Jump.java is compiled and executed with command-line arguments "crazy", "elephant", "is", "always", resulting in args[1] (elephant) being used in the output.
Question
Given:
And the commands:
Javac Jump.java Java Jump crazy elephant is always What is the result?
Exhibit
Options
- ALazy lion is jumping
- BLion is always jumping
- CCrazy elephant is jumping
- DElephant is always jumping
- ECompilation fails
How the community answered
(23 responses)- A4% (1)
- B9% (2)
- C9% (2)
- D78% (18)
Why each option
The Java program `Jump.java` is compiled and executed with command-line arguments "crazy", "elephant", "is", "always", resulting in `args[1]` (elephant) being used in the output.
This output implies a different set of arguments or a different index being accessed, which does not match `args[1]` from the given command.
This output implies a different set of arguments or a different index being accessed, which does not match `args[1]` from the given command.
This output implies accessing `args[0]` or `args[1]` differently combined with a fixed string not matching " is always jumping".
When the command `Java Jump crazy elephant is always` is executed, the string "elephant" is passed as the second command-line argument, making it accessible via `args[1]` in the `main` method. The program then concatenates `args[1]` with the literal string " is always jumping" to produce "Elephant is always jumping".
The problem statement specifies that `Javac Jump.java` succeeded, and the `Java Jump` command is syntactically correct for execution, indicating no compilation or basic execution failures.
Concept tested: Java command-line arguments processing
Source: https://docs.oracle.com/javase/tutorial/getStarted/application/index.html
Topics
Community Discussion
No community discussion yet for this question.
