Page 1 of 1
About Question enthuware.ocpjp.v7.2.1120 :
Posted: Wed Oct 24, 2012 4:13 am
by D3x!
just curious, as String cannot be extended surely it can only be of type String and nothing else?
list is a List of some class that extends from String. It may not necessarily be String. Therefore, you cannot add a String to list.
Re: About Question enthuware.ocpjp.v7.2.1120 :
Posted: Thu Oct 25, 2012 8:27 am
by admin
What you say is correct but it does not apply to declarations that use generics. Ideally, compiler should not even allow List<? extends String> because String is final. But I guess it might lead to complications if, for example, a class is later on made non-final (or final) and that is why it does not check whether the class is final or not.
HTH,
Paul.
Re: About Question enthuware.ocpjp.v7.2.1120 :
Posted: Fri Oct 26, 2012 12:03 am
by D3x!
great point thanks.
Re: About Question enthuware.ocpjp.v7.2.1120 :
Posted: Thu Jan 17, 2013 10:10 am
by lbunschoten
Very hard to answer this question correctly as none of the answers compile. A String can't be added to a list which requires a Shape. Also the methods have a parameter 'strList'. You would expect a list of Strings. However in all examples it is a list of Shapes. Even if you would replace Shape with String for each individual parameter, it would still leave you with four incorrect options.
So I assume there is something wrong with this question or am I doing something wrong?
Re: About Question enthuware.ocpjp.v7.2.1120 :
Posted: Thu Jan 17, 2013 11:42 am
by admin
You are right. This question was modified recently to use Shape instead of String and that introduced the error.
The line :
should actually be
Options 2 and 3 are correct based on that.
This should be fixed asap.
thank you for your feedback.