Code: Select all
The signature of a method in a class is as follows:
public static <E extends CharSequence> List<? super E> doIt(List<E> nums)
This method is being called in the following code:
result = doIt(in);
"Given that String implements CharSequence interface, what should be the reference type of in and result variables?"
It is not specifically stated that String* is used as an input parameter and thus I consider this irrelevant information.
As a result I expect that any class that IS-A CharSequence* can be provided as input.
Yet the answer states this is valid:
input = ArrayList<String> in
--> This answer, however, does not support all cases of IS-A CharSequence* and thus should not be a valid answer at all.
* As type in a List.
Is this question a case of "the exam can contain a question with similar wording and I am simply training you to be aware of it."?