Glen Iris wrote:I do not understand why using D is correct.
Well, I've not seen the other options yet, but as per code, below things are clear:
1) method accepts List of type E
2) method returns List of type E
3) E must be IS-A Number
Option D satisfies all these requirements.
Glen Iris wrote:Why is it ok for the method to declare that it will accept a list - and the accept an ArrayList
because, ArrayList IS-A List.
Glen Iris wrote:When it is not ok for the return type to declare as a List but not return an ArrayList?
if return type is List, method must return something which IS-A list.
I hope this helps.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)