Q. 29 Given the following class definition, which command will cause the application to output the message White-tailed?
A. java forest.Deer deer 5 "White-tailed deer"Your selection is incorrect
B. java forest.Deer "White-tailed deer" deer 3
C. java forest.Deer Red deer White-tailed deer
D. java forest.Deer My "deer White-tailed"
The application prints the third argument of the input methods. Note that double quotes "" group input arguments.
Therefore, the third argument of Option A is White-tailed deer. The third argument of Option B is 3.
The third argument of Option C is White-tailed, making it the correct answer.
Finally, Option D only has two input arguments, leading to an ArrayIndexOutOfBoundsException trying to read the third argument at runtime.
However, my answer would be "Code does not compile, as 'theInput' is undefined".
Wrote and run this piece of code and indeed the result is compilation error:
Deer.java:7: error: cannot find symbol
symbol: variable theInput
location: class Deer
Not able to find this topic in the blog, please point me to it if already reported.