About Question enthuware.ocajp.i.v7.2.1293 :
Posted: Mon Nov 25, 2013 3:44 pm
Just to be clear I'll state the question: "Which of the following correctly defines a method named stringProcessor that can be called by other programmers as follows: stringProcessor(str1) or stringProcessor(str1, str2) or stringProcessor(str1, str2, str3), where str1, str2, and str3 are references to Strings.".
The question bank lists this answer as correct: "public void stringProcessor(String... strs){ }". I think that's wrong, and here's why: the question does not ask for method that can be called with an arbitrary number of arguments (including none). It very clearly asks for the possibility of calling it with 1, 2 or 3 arguments of type String. Hence, I think that the last answer ("Three separate methods need to be written.") is correct.
I agree that the question is open to interpretation - it does not state that the list is exhaustive. Nevertheless, I think that my interpretation is more logically sound - if the list is not exhaustive, then why assume that stringProcessor(str1, str2, str3, int1) should not be included?
My main point here is not that one answer or the other is correct, but that the question is vague. Please correct it.
The question bank lists this answer as correct: "public void stringProcessor(String... strs){ }". I think that's wrong, and here's why: the question does not ask for method that can be called with an arbitrary number of arguments (including none). It very clearly asks for the possibility of calling it with 1, 2 or 3 arguments of type String. Hence, I think that the last answer ("Three separate methods need to be written.") is correct.
I agree that the question is open to interpretation - it does not state that the list is exhaustive. Nevertheless, I think that my interpretation is more logically sound - if the list is not exhaustive, then why assume that stringProcessor(str1, str2, str3, int1) should not be included?
My main point here is not that one answer or the other is correct, but that the question is vague. Please correct it.